洛谷p1198 最大数
2024-08-30 11:06:13
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int m,d,head,tail,pos;
char op[2];
typedef long long ll;
int q[200007],a[200007];
int main(){
while(~scanf("%d%d",&m,&d)){
int t=0,x;head=tail=0;
while(m--){
scanf("%s%d",op,&x);
if(op[0]=='A'){
x=(x+t)%d;
a[pos++]=x;
if(tail==0){
q[tail++]=pos-1;
}
else{
while(tail&&a[q[tail-1]]<=x) tail--;//err
q[tail++]=pos-1;
}
}
else{
int index=lower_bound(q,q+tail,pos-x+1-1)-q;
t=a[q[index]];//err
printf("%d\n",a[q[index]]);
}
}
}
return 0;
}
最新文章
- autofac 组件的实例范围
- 后移动互联网时代:到底还要不要开发一个App?
- MySQL错误:The user specified as a definer (XXX@XXX) does not exist
- 设置Safari浏览器在标签栏上打开新窗口,而不是弹出一个新窗口
- 分享一些Comet开发经验
- POJ 3186 Treats for the Cows 一个简单DP
- 使用C语言实现二维,三维绘图算法(2)-解析曲面的显示
- C#操作AD及Exchange Server总结
- window.atob()与window.btoa()方法实现编码与解码
- Swift内部类调用外部类方法、属性的变通
- Jenkins 集群搭建
- Mac电脑C语言开发的入门帖
- RPC理论以及Dubbo的使用介绍
- 项目管理软件 GanttProject 节日表
- (1)Jquery1.8.3快速入门_helloworld
- React.js 开发参见问题 Q&;A
- lanmp环境一键安装
- 20155205 《Java程序设计》实验四 Android程序设计
- 微信小程序报Cannot read property &#39;setData&#39; of undefined的错误
- ThinkPHP中create()方法自动验证表单信息