BZOJ 1012: [JSOI2008]最大数maxnumber
来源:互联网 发布:nginx 二级域名重定向 编辑:程序博客网 时间:2024/06/11 01:58
1012: [JSOI2008]最大数maxnumber
Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 10176 Solved: 4468
[Submit][Status][Discuss]
Description
现在请求你维护一个数列,要求提供以下两种操作:1、 查询操作。语法:Q L 功能:查询当前数列中末尾L
个数中的最大的数,并输出这个数的值。限制:L不超过当前数列的长度。2、 插入操作。语法:A n 功能:将n加
上t,其中t是最近一次查询操作的答案(如果还未执行过查询操作,则t=0),并将所得结果对一个固定的常数D取
模,将所得答案插入到数列的末尾。限制:n是非负整数并且在长整范围内。注意:初始时数列是空的,没有一个
数。
Input
第一行两个整数,M和D,其中M表示操作的个数(M <= 200,000),D如上文中所述,满足D在longint内。接下来
M行,查询操作或者插入操作。
Output
对于每一个询问操作,输出一行。该行只有一个数,即序列中最后L个数的最大数。
Sample Input
5 100
A 96
Q 1
A 97
Q 1
Q 2
A 96
Q 1
A 97
Q 1
Q 2
Sample Output
96
93
96
93
96
HINT
Source
#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<cstring>#include<ctime>#include<queue>using namespace std;const int maxn = 250001;inline int read(){int x = 0 , f = 1; char ch = getchar();while(ch<'0'||ch>'9'){if(ch=='-') f= -1; ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+(ch-'0');ch=getchar();}return x * f;}int a[maxn],maxnum[maxn];int m,d,k,t;int main(){ scanf("%d%d",&m,&d); for(int i=0; i<m; i++){ char op[2]; scanf("%s",op); if(op[0] == 'A'){int x = read(); a[++t] = (x+k)%d; for(int i=t; i>0; i--) if(maxnum[i] < a[t]) maxnum[i] = a[t]; else break; }else{ int x = read(); k = maxnum[t-x+1]; printf("%d\n",k); } } return 0;}
阅读全文
0 0
- BZOJ 1012: [JSOI2008]最大数maxnumber
- BZOJ 1012 [JSOI2008]最大数maxnumber
- BZOJ 1012: [JSOI2008]最大数maxnumber
- [BZOJ 1012][JSOI2008]最大数maxnumber
- BZOJ 1012: [JSOI2008]最大数maxnumber
- bzoj 1012: [JSOI2008]最大数maxnumber 二分
- bzoj 1012 [JSOI2008]最大数maxnumber
- [BZOJ 1012] [JSOI2008] 最大数maxnumber
- 【BZOJ 1012】[JSOI2008]最大数maxnumber
- BZOJ 1012:[JSOI2008]最大数 maxnumber
- bzoj 1012 [JSOI2008]最大数maxnumber
- 【BZOJ 1012】 [JSOI2008]最大数maxnumber
- bzoj 1012 [JSOI2008]最大数maxnumber
- BZOJ 1012 [JSOI2008]最大数maxnumber
- BZOJ 1012 [JSOI2008]最大数maxnumber
- BZOJ 1012: [JSOI2008]最大数maxnumber
- BZOJ 1012: [JSOI2008]最大数maxnumber
- bzoj 1012: [JSOI2008]最大数maxnumber
- Zoj 3261 Connections in Galaxy War【逆序并查集】
- 【ARM】ARM接口技术
- keil c51/keil4 安装教程
- (转)最近100年全球最顶尖公司的共性
- 图的表示
- BZOJ 1012: [JSOI2008]最大数maxnumber
- HTTP报文(http权威指南第三章)
- windows平台下一次创建多级目录
- 选择状态
- C语言判断一个数是否为素数
- 堆排序
- HTTP简介
- Libevent源码分析-----信号event的处理
- arm+Linux