http://cogs.pro:8080/cogs/problem/problem.php?pid=1844

Luogu 的数据真zhizhang

Cogs AC

#include <iostream>
#include <cstdio>
#include <algorithm> using namespace std; #define gc getchar()
#define LL long long const LL oo = ;
const int N = 2e5 + ; LL n, Mod, Answer, tot;
LL Max[N << ]; #define lson jd << 1
#define rson jd << 1 | 1 void Build_tree(int l, int r, int jd) {
Max[jd] = -oo;
if(l == r) return ;
int mid = (l + r) >> ;
Build_tree(l, mid, lson);
Build_tree(mid + , r, rson);
} void Poi_G(int l, int r, int jd, int x, LL num) {
if(l == r) {Max[jd] = num; return ;}
int mid = (l + r) >> ;
if(x <= mid) Poi_G(l, mid, lson, x, num);
else Poi_G(mid + , r, rson, x, num);
Max[jd] = max(Max[lson], Max[rson]);
} void Sec_A(int l, int r, int jd, int x, int y) {
if(x <= l && r <= y) {Answer = max(Answer, Max[jd]); return ;}
int mid = (l + r) >> ;
if(x <= mid) Sec_A(l, mid, lson, x, y);
if(y > mid) Sec_A(mid + , r, rson, x, y);
} int main() {
cin >> n >> Mod;
Build_tree(, n, );
int m = n;
while(m --) {
char c;
cin >> c;
if(c == 'A') {
LL num;
cin >> num;
tot ++;
Poi_G(, n, , tot, (Answer + num) % Mod);
} else {
int len;
cin >> len;
if(!len) {cout << ; break;}
Answer = - oo;
Sec_A(, n, , tot - len + , tot);
cout << Answer << endl;
}
} return ;
}

[Cogs] 最大数maxnumber的更多相关文章

  1. Cogs 1844. [JSOI2008]最大数maxnumber

    [JSOI2008]最大数maxnumber ★★ 输入文件:bzoj_1012.in 输出文件:bzoj_1012.out 简单对比 时间限制:3 s 内存限制:162 MB [题目描述] 现在请求 ...

  2. BZOJ1012: [JSOI2008]最大数maxnumber [线段树 | 单调栈+二分]

    1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 8748  Solved: 3835[Submi ...

  3. BZOJ-1012[JSOI2008]最大数maxnumber 线段树区间最值

    这道题相对简单下面是题目: 1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MB Submit: 6542 Solve ...

  4. 【BZOJ】【1012】【JSOI2008】最大数maxnumber

    线段树 ……现在再来看这题感觉好水啊,当年的大老虎现在也变成小花猫了,真是令人感动<_< /************************************************ ...

  5. 【bzoj1012】[JSOI2008]最大数maxnumber

    1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 8339  Solved: 3624[Submi ...

  6. 【单调栈】Bzoj 1012: 最大数maxnumber

    1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 6255  Solved: 2676[Submi ...

  7. BZOJ 1012: [JSOI2008]最大数maxnumber【线段树单点更新求最值,单调队列,多解】

    1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 10374  Solved: 4535[Subm ...

  8. [JSOI2008]最大数maxnumber

    [JSOI2008]最大数maxnumber 标签: 线段树 单独队列 题目链接 题解 线段树裸题. 如果一直RE可能是你用的cin/cout. Code #include<cstdio> ...

  9. BZOJ 1012--[JSOI2008]最大数maxnumber(二分&单调栈)

    1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 14142  Solved: 6049[Subm ...

随机推荐

  1. Python 【格式化字符串】

    print('血量:'+str(player_life)+' 攻击:'+str(player_attack)) 第一种格式化字符串 print('血量:%s 攻击:%s' % (player_life ...

  2. k8s之资源指标API部署metrics-server

    1.部署metrics-server 从v1.8开始,引入了新的功能,即把资源指标引入api,资源指标:metrics-server,自定义指标:prometheus,k8s-prometheus-a ...

  3. iview表单验证数字

    验证输入字符串必须为数字 html: <FormItem label="兑换积分:" prop="exchangeIntegral"> <In ...

  4. css的一些样式

    input标签中的一些样式: <input type="text">:表示输入文本 <input type="password">:表示 ...

  5. 浏览器本质上是解析器javascript

    浏览器本质上是解析器.用于将符合W3C的标记序列解析并还原到编码人员希望用户看到的呈现状态.实际上,Word本身也可以看作是一个文档文件浏览器,acdsee是一个图像文件解析器(浏览器).HTML文件 ...

  6. python中的% 是什么意思, 起到什么作用?

    %Y会被无世纪的年份所替代.%m会被01到12之间的一个十进制月份数替代,其他依次类推. 1.%在python的格式化输出,有转换字符的飞鲸作用: (1)%c 整数转成对应的 ASCII 字元: (2 ...

  7. json树迭代

    getArray(data){ for (var i in data) { if(data[i].disabled){ data[i].disabled = false } if(data[i].ch ...

  8. BBPlus团队ALPHA冲刺博客(肖文恒)

    ALPHA冲刺博客 第一天:https://www.cnblogs.com/bbplus/p/11931039.html 第二天:https://www.cnblogs.com/bbplus/p/11 ...

  9. String类-StringBuffer类-StringBuilder类的比较

    package LC20130929; /**  * 字符串处理类: StringBuffer ~~ StringBuilder 〉〉 String   效果一样但是,性能却大不一样!         ...

  10. 深度排序模型概述(二)PNN/NFM/AFM

    在CTR预估中,为了解决稀疏特征的问题,学者们提出了FM模型来建模特征之间的交互关系.但是FM模型只能表达特征之间两两组合之间的关系,无法建模两个特征之间深层次的关系或者说多个特征之间的交互关系,因此 ...