传送门: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. mysql查询今天,昨天,近7天,近30天,本月,上一月数据的SQL

    原文:http://www.open-open.com/code/view/1423207309170 select * from ad_proTrack_t where to_days(crt_ti ...

  2. OCR简介及使用

    OCR (Optical Character Recognition,光学字符识别)是指电子设备(例如扫描仪或数码相机)检查纸上打印的字符,通过检测暗.亮的模式确定其形状,然后用字符识别方法将形状翻译 ...

  3. Linux 上运行 mapreduce 类型错误

    1.ClassCastException 错误代码 /** * */ /** * @author hadoop * */ package WordCount; import java.io.IOExc ...

  4. [Angular] Refactor Angular Component State Logic into Directives

    Allow the base toggle to be a tag (<toggle>) or attribute (<div toggle>). The <toggle ...

  5. 阅读《Android 从入门到精通》(33)——Intent 分类

    Intent 分类 显式 Intent:Intent("android.intent.action.CALL", Uri.parse("tel:" + stri ...

  6. 五分钟搭建 Flash 视频直播站

    想在家里对全世界直播网络视频节目吗?如今视频网站是多如牛毛,但能让你玩直播的估计没几个吧?看完这篇教程就能帮你实现网络主持人的梦想.不花钱,不懂编程,不用写代码也行哦~ 首先是最低机器要求:Windo ...

  7. 如约而至,Java 10 正式发布! Spring+SpringMVC+MyBatis+easyUI整合进阶篇(十四)Redis缓存正确的使用姿势 努力的孩子运气不会太差,跌宕的人生定当更加精彩 优先队列详解(转载)

    如约而至,Java 10 正式发布!   3 月 20 日,Oracle 宣布 Java 10 正式发布. 官方已提供下载:http://www.oracle.com/technetwork/java ...

  8. 基于github for windows&amp;github的团队协作基本操作

    首先,我们要在github上团队协作.先要建立一个team.这个自行百度,在github上操作就是. 点击打开链接 这是我的有道文章(假设看不到图片的话) 今天主要讲的是怎么操作github for ...

  9. iPhone开发关于UDID和UUID的一些理解【转】

    原文地址:http://blog.csdn.net/xunyn/article/details/13629071 一.UDID(Unique Device Identifier) UDID是Uniqu ...

  10. 2016/3/31 拾遗 php字符串中 转义字符 “ ’‘ ” ’ “” ‘ " \’ ' ' \‘ " " \" '' \ " " 使用

    <?php echo $str_string1='甲问:"你在哪里学的PHP?"'; echo "<br />"; echo $str_str ...