BZOJ 1012
题解:用单调栈来维护第L大的数这个关系
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 const int N=2e5+5; 5 int a[N],data[N]; 6 int main(){ 7 ????int m,d; 8 ????scanf("%d %d",&m,&d); 9 ????char str[2];10 ????int x,t=0,len=0,top=0;11 ????for(int i=0;i<m;i++){12 ????????scanf("%s%d",str,&x);13 ????????if(str[0]==‘A‘){14 ????????????x=(x+t)%d;15 ????????????data[++len]=x;16 ????????????while(top&&data[a[top]]<=x)top--;17 ????????????a[++top]=len;18 ????????}19 ????????else{20 ????????????int index=lower_bound(a+1,a+1+top,len-x+1)-a;21 ????????????t=data[a[index]];22 ????????????printf("%d\n",t);23 ????????}24 ????}25 ????26 ????return 0;27 }
BZOJ 1012 ?[JSOI2008]最大数maxnumber
原文地址:https://www.cnblogs.com/Mrleon/p/8407308.html