| 比赛 |
2026.9.5 |
评测结果 |
AAAAAAAAAAAAAAA |
| 题目名称 |
To-Do List |
最终得分 |
100 |
| 用户昵称 |
李金泽 |
运行时间 |
8.553 s |
| 代码语言 |
C++ |
内存使用 |
42.56 MiB |
| 提交时间 |
2026-09-05 08:47:35 |
显示代码纯文本
#include<bits/stdc++.h>
#define N 1000005
#define int long long
#define db double
#define ls(x) x<<1
#define rs(x) x<<1|1
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)
using namespace std;
int T,n,m,k,x,y,z,cnt,ans,last,as[N],at[N];
int t[N<<2],sum[N<<2];
const int maxs=1e6,p=1e6+3;
char op[2];
void swap(int &x,int &y){int t=x;x=y;y=t;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x<y?x:y;}
void ckmax(int &x,int y){if(y>x)x=y;}
void ckmin(int &x,int y){if(y<x)x=y;}
int read(){
int sum=0;bool f=0;char c=getchar();
for(;c<48||c>57;c=getchar())if(c==45)f=1;
for(;c>=48&&c<=57;c=getchar())sum=sum*10+(c&15);
return f?-sum:sum;
}
void pu(int x){
sum[x]=sum[ls(x)]+sum[rs(x)];
t[x]=max(t[rs(x)],t[ls(x)]+sum[rs(x)]);
}
void ud(int l,int r,int s,int x,int k){
if(l==r){
if(!t[x])t[x]=s;
t[x]+=k;
if(t[x]==s)t[x]=0;
sum[x]+=k;
return;
}
int mid=l+r>>1;
if(s<=mid)ud(l,mid,s,ls(x),k);
else ud(mid+1,r,s,rs(x),k);
pu(x);
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);
freopen("List.in","r",stdin);freopen("List.out","w",stdout);
m=read();
while(m--){
scanf("%s",op);
if(op[0]=='A'){
x=(last+read())%p-1;y=(last+read())%p;
cnt++;
as[cnt]=x;at[cnt]=y;
ud(0,maxs,x,1,y);
}
else{
x=(last+read())%p;
ud(0,maxs,as[x],1,-at[x]);
}
printf("%lld\n",last=t[1]);
}
return 0;
}