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. XML文件介绍

    xml基础详解 1.概述: xml:即可扩展标记语言,xml是互联网数据传输的重要工具,它可以跨越互联网的任何平台,不受编程语言和操作系统的限制,可以说他是一个拥有互联网最高级别通行证的数据携带者.x ...

  2. PHP学习之迭代生成器

    生成器的核心是一个yield关键字,一个生成器函数看起来像一个普通的函数,不同的是.普通函数返回一个值,而一个生成器可以yield生成许多它所需要的值.生成器函数被调用时,返回的是一个可以被遍历的对象 ...

  3. MyBatis学习存档(4)——进行CRUD操作

    使用MyBatis进行数据库的CRUD操作有2种方式:一种如之前所说的接口+xml,而另一种是通过对接口上的方法加注解(@Select @Insert @Delete @Update) 但是通常情况下 ...

  4. Attribute预定义特性

    转载自:http://blog.csdn.net/wangyy130/article/details/44241173 一.什么是Attribute Attribute 类将预定义的系统信息或用户定义 ...

  5. ubuntu目录结构(转)

    /:根目录,一般根目录下只存放目录,不要存放文件,/etc./bin./dev./lib./sbin应该和根目录放置在一个分区中 /bin:/usr/bin:可执行二进制文件的目录,如常用的命令ls. ...

  6. property配置

    之前把设备历史数据存储的时间周期存储在了数据库中,因为以下一些原因,我打算改写到property配置文件中 1.这个周期时间的配置没有单独放一个tabel中,导致现在设备类型越来越多,每次添加或者修改 ...

  7. 2.1 使用JAXP 对 xml文档进行DOM解析

    //使用 jaxp 对xml文档进行dom解析 public class Demo2 { //必要步骤 @Test public void test() throws Exception { //1. ...

  8. Linux 虚拟机扩容

    由于在装软件,原来的20G空间不够使用,需要扩容操作. 1.关闭虚拟机 2.点击编辑虚拟机设置 选中硬盘,添加,硬盘,推荐,确定大小,完成. 2.启动虚拟机 查看磁盘使用情况: [root@maste ...

  9. Computer Vision_1_Active Appearance Models:Active Appearance Models——2001

    此为计算机视觉部分,主要侧重在底层特征提取,视频分析,跟踪,目标检测和识别方面等方面. 1. Active Appearance Models 活动表观模型和活动轮廓模型基本思想来源 Snake,现在 ...

  10. Flutter——Column组件(垂直布局组件)

    Column组件的常用属性 属性 说明 mainAxisAlignment 主轴的排序方式 crossAxisAlignment 次轴的排序方式 children 组件子元素 import 'pack ...