牛客练习赛102 B-C

 

当数大于 1e9的时候就取模

复制代码
//#define int ll
const int N = 1e5+10,mod = 19980829;
int n,m;
void solve() {
    ll res = 0;
    bool flag = false;
    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i ++) {
        ll a, b;
        cin >> a >> b;
        if((!flag && !res) || b == 1) res += a;
        else if(flag) res *= b;
        else {
            ll mul = (b - 1) * res;
            if(mul > a) res += mul;
            else res += a;
        }
        if(flag || res > 1e9) {
            res %= mod;
            flag = true;
        }
    }
    cout << res << "\n";
}
复制代码

对右坐标,左坐标,需要的值的数目排序

复制代码
//#define int ll
const int N = 1e5+10;
int n,m;

bool vis[N];
int a[N];

struct node {
    int l,r;
    int x,y;
    bool operator<(const node & T) const {
        if(l == T.l) return r < T.r;
        
        return l<T.l;
    }
} p[N];

void solve()
{
    cin>>n>>m;
    fo(i,1,m) {
        int l,r,x,y;cin>>l>>r>>x>>y;
        p[i] = {l,r,x,y};
    }
    sort(p+1,p+1+m);
    int idx = 1;
    fo(i,1,m) {
        
        fo(j,p[i].l,p[i].r) {
            if(p[i].y == 0) break;
            if(!a[j]){a[j] = p[i].x;p[i].y -- ;}
        }
        if(p[i].y) {
             cout<<"qcjjddw"<<endl;
            rt;
        }
    }
    fo(i,1,n) {
        if(!a[i]) {
            a[i] = 1;
        }
    }
    fo(i,1,n) {
        cout<<a[i]<<' ';
    }
}
复制代码

 

posted @   er007  阅读(53)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
点击右上角即可分享
微信分享提示