求助,帮改P1198 [JSOI2008] 最大数
  • 板块灌水区
  • 楼主qsy13688006858
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/7/26 11:26
  • 上次更新2023/11/3 07:36:19
查看原帖
求助,帮改P1198 [JSOI2008] 最大数
1043700
qsy13688006858楼主2023/7/26 11:26

求大佬帮改 P1198

#include<bits/stdc++.h>
using namespace std;
int n,d,t,x,a[200005],b[200005],sz,cnt;
char op;
int main() {

	cin>>n>>d;
	for(int i=1; i<=n; i++)
	{
		cin>>op>>x;
		if(op=='A') {
			a[++cnt]=(x+t)%d;
			while(sz&&a[cnt]) sz--;
			b[sz++]=cnt;
		} else if(op=='Q') {
			int p=lower_bound(b,b+sz,cnt-x+1)-b;
			t=a[b[p]];
			cout<<t<<endl;
		}
		
	}
}

2023/7/26 11:26
加载中...