1.最大数
代码:
#include <stdio.h> #include <memory.h> #include <math.h> #include <string> #include <vector> #include <set> #include <stack> #include <queue> #include <algorithm> #include <map> #define I scanf #define OL puts #define O printf #define F(a,b,c) for(a=b;a<c;a++) #define FF(a,b) for(a=0;a<b;a++) #define FG(a,b) for(a=b-1;a>=0;a--) #define LEN 200010 #define MAX 1<<30 #define V vector<int> #define ll long long using namespace std; inline ll max(ll a,ll b){ return a>b?a:b; } int T,i; ll D,t=0; ll q[LEN],a[LEN]; int len=0; int main(){ freopen("最大数.txt","r",stdin); I("%d%lld",&T,&D); while(T--){ char buf[10]; ll num; I("%s%lld",buf,&num); if(buf[0]==‘A‘){ a[++len]=(num+t)%D; for(i=len;i>=1;i--){ if(q[i]<a[len]) q[i]=a[len]; else break; } }else{ printf("%lld\n",t=q[len-num+1]); } } return 0; }
理解:
原文地址:https://www.cnblogs.com/TQCAI/p/8453236.html
时间: 2024-10-09 23:29:42