[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 ...
随机推荐
- LC 349. Intersection of Two Arrays
题目描述 Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1, ...
- S02_CH16 等精度频率计实验
S02_CH16 等精度频率计实验 在了解了AXI总线之后,今天我们自己动手设计一个带AXI4-Lite总线的IP,来完成频率计的实验. 频率计虽然小,但是也算五脏俱全,涉及到zynq的方方面面,比如 ...
- MySQL 数据库面试题
原文出处:https://juejin.im/post/5a9ca0d6518825555c1d1acd 作者:Java3y 本文在原文基础上进行修改,而且没有特定针对MySQL. 一.存储过程(以及 ...
- python 拟合曲线并求参
需要对数据进行函数拟合,首先画一下二维散点图,目测一下大概的分布, 所谓正态分布,就是高斯分布,正态曲线是一种特殊的高斯曲线. python的scipy.optimize包里的curve_fit函数来 ...
- 检索 COM 类工厂中 CLSID 为 {13C28AD0-F195-4319-B7D7-A1BDAA329FB8} 的组件失败,原因是出现以下错误: 80040154 没有注册类 (异常来自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG))。
上午前客户突然来电说换了台电脑重新装的程序不能正常用,发来错误提示如图: 这错误显然不是程序错误,异常写的很清楚 ,COM组件没注册,搜一下CLSID, 原来是GridReport++ ,参考地址: ...
- MediaAPIController
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.D ...
- 如何确定asp.net请求生命周期的当前处理事件
1 首先在全局应用程序里面添加如下代码 using System; using System.Collections.Generic; using System.Linq; using System. ...
- boost交叉编译
运行bootstrap.sh # ./bootstrap.sh 生成b2.bjam和project-config.jam文件 修改project-config.jam using gcc : arm ...
- jQuery EasyUI 应用 – 创建 CRUD 应用(表格)
jQuery EasyUI 应用 - 创建 CRUD 应用 本节介绍如何创建CRUD应用. CRUD分别是指在做计算处理时的增加(Create).读取查询(Retrieve).更新(Update)和删 ...
- TCP-HTTP ___UDP 应用场景
UDP 套接字应用之广播 import socket,threading #创建套接字 s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) # 设置套接 ...