比赛 2026.9.5 评测结果 WATTTTTTTTTTTTT
题目名称 To-Do List 最终得分 6
用户昵称 汐汐很希希 运行时间 66.555 s
代码语言 C++ 内存使用 41.65 MiB
提交时间 2026-09-05 11:17:01
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+10;
const int mod=1e6+3;
ll q,last=0,cnt=0,cd=0;
struct Node{
    ll l,r,len;
}a[N],t[N];
bool cmp(Node &x,Node &y){
    if(x.l==y.l) return x.r<y.r;
    return x.l<y.l;
}
void work()
{
    for(int i=1;i<=cnt;i++) t[i]=a[i];
    sort(t+1,t+cnt+1,cmp);
    ll sum=0,tt=0;
    for(int i=1+cd;i<=cnt;i++){
        if(t[i].l<=0) continue;
        if(t[i].l>t[i-1].r+tt) sum=t[i].l-1;
        else if(t[i].l<=t[i-1].r+tt) tt=t[i-1].r+tt-t[i].l+1;
        sum+=t[i].len;
    }
    cout<<sum<<endl;
    last=sum;
    return;
}
int main()
{
    freopen("List.in","r",stdin);
    freopen("List.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>q;
    while(q--){
        char op;
        cin>>op;
        if(op=='A'){
            int s,t;
            cin>>s>>t;
            s=(s+last)%mod,t=(t+last)%mod;
            a[++cnt].l=s,a[cnt].r=s+t-1,a[cnt].len=t;
        }else if(op='D'){
            int x;
            cin>>x;
            x=(x+last)%mod;
            a[x]={0,0};
            cd++;
        }
        if(q<=5000) work();
    }
    return 0;
}