比赛 2026.9.5 评测结果 AAAAAAAAAAAAAAA
题目名称 To-Do List 最终得分 100
用户昵称 小福鑫 运行时间 40.238 s
代码语言 C++ 内存使用 48.50 MiB
提交时间 2026-09-05 10:40:55
显示代码纯文本
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000003;
int q,mx[4000010],lz[4000010],cnt[1000010],s[1000010],t[1000010],last,tot,a,b,x;
char op;
void update(int k,int l,int r,int x,int y,int v){
	if(x<=l&&r<=y){
		mx[k]+=v;
		lz[k]+=v;
		return;
	}
	if(lz[k]){
		mx[k*2]+=lz[k];
		mx[k*2+1]+=lz[k];
		lz[k*2]+=lz[k];
		lz[k*2+1]+=lz[k];
		lz[k]=0;
	}
	int mid=(l+r)>>1;
	if(x<=mid) update(k*2,l,mid,x,y,v);
	if(y>mid) update(k*2+1,mid+1,r,x,y,v);
	mx[k]=max(mx[k*2],mx[k*2+1]);
}
signed main(){
    freopen("List.in","r",stdin);
    freopen("List.out","w",stdout);
	cin>>q;
	while(q--){
		cin>>op;
		if (op=='A') {
			cin>>a>>b;
			a=(a+last)%mod,b=(b+last)%mod;
			s[++tot]=a,t[tot]=b;
			update(1,1,1000010,1,a,b);
			if(cnt[a]==0) update(1,1,1000010,a,a,a-1);
			cnt[a]++;
		}
        else{
			cin>>x;
			x=(x+last)%mod;
			update(1,1,1000010,1,s[x],-t[x]);
			cnt[s[x]]--;
			if(!cnt[s[x]]) update(1,1,1000010,s[x],s[x],-(s[x]-1));
		}
		last=mx[1];
		cout<<last<<"\n";
	}
}