| 比赛 |
2026.9.5 |
评测结果 |
AAAAAWWWWWAAAAA |
| 题目名称 |
To-Do List |
最终得分 |
65 |
| 用户昵称 |
VTXE |
运行时间 |
12.233 s |
| 代码语言 |
C++ |
内存使用 |
87.05 MiB |
| 提交时间 |
2026-09-05 09:35:17 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll p=1e6+3;
struct node{
ll l,r;
ll sm,mx;
}t[4000400];
ll q;
char c;
ll lst;
ll sa[1000100],ta[1000100],ct[1000100];
ll cnt;
void pushup(ll o){
t[o].sm=t[o*2].sm+t[o*2+1].sm;
t[o].mx=max(t[o*2+1].mx,t[o*2].mx+t[o*2+1].sm);
}
void build(ll o,ll l,ll r){
t[o].l=l;t[o].r=r;
t[o].sm=0;t[o].mx=-1e18;
if (l==r) return;
ll mid=(l+r)/2;
build(o*2,l,mid);
build(o*2+1,mid+1,r);
}
void update(ll o,ll ps,ll v,ll tot){
if (t[o].l==t[o].r){
ct[t[o].l]+=tot;
t[o].sm+=v;
if (ct[t[o].l]>0) t[o].mx=ps+t[o].sm;
else t[o].mx=-1e18;
return;
}
ll mid=(t[o].l+t[o].r)/2;
if (ps<=mid) update(o*2,ps,v,tot);
else update(o*2+1,ps,v,tot);
pushup(o);
}
int main(){
freopen("List.in","r",stdin);
freopen("List.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>q;
build(1,1,1000010);
ll s,tt,x;
for (int i=1;i<=q;i++){
cin>>c;
if (c=='A'){
cin>>s>>tt;
s=(s+lst)%p-1;
tt=(tt+lst)%p;
sa[++cnt]=s;
ta[cnt]=tt;
update(1,s,tt,1);
}else{
cin>>x;
x=(x+lst)%p;
update(1,sa[x],-ta[x],-1);
}
lst=t[1].mx;
cout<<lst<<'\n';
}
return 0;
}