[Cogs] 最大数maxnumber
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的更多相关文章
- Cogs 1844. [JSOI2008]最大数maxnumber
[JSOI2008]最大数maxnumber ★★ 输入文件:bzoj_1012.in 输出文件:bzoj_1012.out 简单对比 时间限制:3 s 内存限制:162 MB [题目描述] 现在请求 ...
- BZOJ1012: [JSOI2008]最大数maxnumber [线段树 | 单调栈+二分]
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 8748 Solved: 3835[Submi ...
- BZOJ-1012[JSOI2008]最大数maxnumber 线段树区间最值
这道题相对简单下面是题目: 1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MB Submit: 6542 Solve ...
- 【BZOJ】【1012】【JSOI2008】最大数maxnumber
线段树 ……现在再来看这题感觉好水啊,当年的大老虎现在也变成小花猫了,真是令人感动<_< /************************************************ ...
- 【bzoj1012】[JSOI2008]最大数maxnumber
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 8339 Solved: 3624[Submi ...
- 【单调栈】Bzoj 1012: 最大数maxnumber
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 6255 Solved: 2676[Submi ...
- BZOJ 1012: [JSOI2008]最大数maxnumber【线段树单点更新求最值,单调队列,多解】
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 10374 Solved: 4535[Subm ...
- [JSOI2008]最大数maxnumber
[JSOI2008]最大数maxnumber 标签: 线段树 单独队列 题目链接 题解 线段树裸题. 如果一直RE可能是你用的cin/cout. Code #include<cstdio> ...
- BZOJ 1012--[JSOI2008]最大数maxnumber(二分&单调栈)
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 14142 Solved: 6049[Subm ...
随机推荐
- k8s之资源指标API部署metrics-server
1.部署metrics-server 从v1.8开始,引入了新的功能,即把资源指标引入api,资源指标:metrics-server,自定义指标:prometheus,k8s-prometheus-a ...
- k8s之RBAC-基于角色的访问控制
一个在名称空间内的对象的完整url模板: Object_URL: /apis/<GROUP>/<VERSION>/namespaces/<NAMESPACE_NAME&g ...
- Asp.net core 学习笔记 ef core Surrogate Key, Natural Key, Alternate Keys
更新: 2019-12-23 foreignkey 并不一样要配上 alternate key,其实只要是 unique 就可以了. 和 sql server 是一样的, 经常有一种错觉 primar ...
- Oracle导入数据后中文乱码的解决方法
解决方法: 方法一. 1.在运行命令行输入regedit,打开注册表编辑器 2.找到HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraDb11g_home1 3.看N ...
- where用法
where 子句用于指定类型约束. 1.接口约束 public class MyGenericClass<T> where T:IComparable { } 2.基类约束: 指出某个类 ...
- [转载]PyTorch中permute的用法
[转载]PyTorch中permute的用法 来源:https://blog.csdn.net/york1996/article/details/81876886 permute(dims) 将ten ...
- python 利用pyttsx3文字转语音(转)
原文链接作者 # -*- coding: utf-8 -*- import pyttsx3 engine = pyttsx3.init() with open("all.txt", ...
- Python之IDE工具下载安装及注册详解及创建项目
这篇文章很适合刚接触python语言的或者没有语言基础的同学参考: 目录: 一.IDE工具下载安装 二.IDE注册方法 三.使用IDE 开发工具使用创建项目 一.下载并安装, IntelliJ IDE ...
- 使用pycharm 编写代码 并在远程主机上运行
一 要求 远程主机有python解释器 二 在菜单栏,File -> Settings… -> Project ×× -> Project Interpreter,点击右侧 Add按 ...
- Short XSS
Short XSS Crackkay · 2013/08/21 12:17 0x00 背景 关键时候长度不够怎么办? 在实际的情况中如果你不够长怎么办呢?看医生?吃药?做手术?............ ...