#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;
}

最新文章

  1. autofac 组件的实例范围
  2. 后移动互联网时代:到底还要不要开发一个App?
  3. MySQL错误:The user specified as a definer (XXX@XXX) does not exist
  4. 设置Safari浏览器在标签栏上打开新窗口,而不是弹出一个新窗口
  5. 分享一些Comet开发经验
  6. POJ 3186 Treats for the Cows 一个简单DP
  7. 使用C语言实现二维,三维绘图算法(2)-解析曲面的显示
  8. C#操作AD及Exchange Server总结
  9. window.atob()与window.btoa()方法实现编码与解码
  10. Swift内部类调用外部类方法、属性的变通
  11. Jenkins 集群搭建
  12. Mac电脑C语言开发的入门帖
  13. RPC理论以及Dubbo的使用介绍
  14. 项目管理软件 GanttProject 节日表
  15. (1)Jquery1.8.3快速入门_helloworld
  16. React.js 开发参见问题 Q&amp;A
  17. lanmp环境一键安装
  18. 20155205 《Java程序设计》实验四 Android程序设计
  19. 微信小程序报Cannot read property &#39;setData&#39; of undefined的错误
  20. ThinkPHP中create()方法自动验证表单信息

热门文章

  1. Nginx架构赏析
  2. centos&amp;linux
  3. 淘宝APP消息推送模型
  4. Linux centos7编译源码安装redis
  5. loj10095 间谍网络
  6. Windows搭建TestLink环境
  7. 十三:SpringBoot-基于Yml配置方式,实现文件上传逻辑
  8. 封装SpringJdbcTemplate
  9. Flink 在又拍云日志批处理中的实践
  10. PostgreSQL 实现定时任务的 4 种方法