传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1012

裸的树状数组。

#include <cstdio>
#include <algorithm> const int maxm = 200005; int m, d, c[maxm], n, t1, t;
char opr; inline void upd(int pos, int val) {
while (pos) {
c[pos] = std::max(c[pos], val);
pos -= (pos & (-pos));
}
}
inline int qry(int pos) {
int rt = -2147483647;
while (pos <= n) {
rt = std::max(rt, c[pos]);
pos += (pos & (-pos));
}
return rt;
} int main(void) {
scanf("%d%d", &m, &d);
while (m--) {
while ((opr = getchar()) < 'A');
scanf("%d", &t1);
if (opr == 'A') {
upd(++n, (int)((long long)(t1 + t) % d));
}
else {
printf("%d\n", t = qry(n - t1 + 1));
}
}
return 0;
}

  

_bzoj1012 [JSOI2008]最大数maxnumber【Fenwick Tree】的更多相关文章

  1. [bzoj1012](JSOI2008)最大数maxnumber(Fenwick Tree)

    Description 现在请求你维护一个数列,要求提供以下两种操作: 1. 查询操作.语法:Q L 功能:查询当前数列中末尾L个数中的最大的数,并输出这个数的值.限制:L不超过当前数列的长度. 2. ...

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

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

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

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

  4. 大视野 1012: [JSOI2008]最大数maxnumber(线段树/ 树状数组/ 单调队列/ 单调栈/ rmq)

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

  5. bzoj-1012 1012: [JSOI2008]最大数maxnumber(线段树)

    题目链接: 1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec  Memory Limit: 162 MB Description 现在请求你维护一个数列,要 ...

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

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

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

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

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

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

  9. [JSOI2008]最大数maxnumber

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

随机推荐

  1. datatable使用介绍

    Datatables是一款jquery表格插件.它是一个高度灵活的工具,可以将任何HTML表格添加高级的交互功能. 1.支持分页:前台分页和后台分页 前台分页:后台一次把数据传过来,交给前端渲染.缺点 ...

  2. ADO.NET(OleDb)读取Excel表格时的一个BUG

    如果我们有例如以下一个Excel表格:    如今要使用C#程序读取其内容: using System;  using System.Data.OleDb;    namespace Skyiv.Be ...

  3. leetcode ----Trie/stack专题

    一:Implement Trie (Prefix Tree) 题目: Implement a trie with insert, search, and startsWith methods. Not ...

  4. Qt Quick 图像处理实例之美图秀秀(附源代码下载)

    在<Qt Quick 之 QML 与 C++ 混合编程具体解释>一文中我们解说了 QML 与 C++ 混合编程的方方面面的内容,这次我们通过一个图像处理应用.再来看一下 QML 与 C++ ...

  5. Idea 13 新建maven项目

    1.此时生成的maven项目没有web文件夹 file→New Project→Maven→Next→GID.AID (NewDemo)→Next→ProjectName(NewDemo)→Finis ...

  6. ansible学习之--简单学习笔记1

    1.利用dm-crypt来创建加密文件系统.编写shell脚本(安装和卸载两个shell脚本) 2.编写ansible,playbook文件 3.编写python脚本 首先编写shell脚本 inst ...

  7. Random-随机生成电话号

    package test1; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; ...

  8. Linux下使用inotify实现对文件的监控

    项目中,要实现用户通过网页设置參数,后台接收数据然后写串口. 网页写数据到本地文件,使用inotify监控文件的IN_MODIFY事件.当文件被改动,然后触发写串口事件. 第一个程序只把要监控的文件增 ...

  9. CXF Spring 使用

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

  10. YTU 2838: 改错题AB-装置连接

    2838: 改错题AB-装置连接 时间限制: 1 Sec  内存限制: 128 MB 提交: 81  解决: 49 题目描述 注:本题只需要提交标记为修改部分之间的代码,请按照C++方式提交. 有AB ...