_bzoj1012 [JSOI2008]最大数maxnumber【Fenwick Tree】
传送门: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】的更多相关文章
- [bzoj1012](JSOI2008)最大数maxnumber(Fenwick Tree)
Description 现在请求你维护一个数列,要求提供以下两种操作: 1. 查询操作.语法:Q L 功能:查询当前数列中末尾L个数中的最大的数,并输出这个数的值.限制:L不超过当前数列的长度. 2. ...
- Cogs 1844. [JSOI2008]最大数maxnumber
[JSOI2008]最大数maxnumber ★★ 输入文件:bzoj_1012.in 输出文件:bzoj_1012.out 简单对比 时间限制:3 s 内存限制:162 MB [题目描述] 现在请求 ...
- BZOJ 1012: [JSOI2008]最大数maxnumber【线段树单点更新求最值,单调队列,多解】
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 10374 Solved: 4535[Subm ...
- 大视野 1012: [JSOI2008]最大数maxnumber(线段树/ 树状数组/ 单调队列/ 单调栈/ rmq)
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 9851 Solved: 4318[Submi ...
- bzoj-1012 1012: [JSOI2008]最大数maxnumber(线段树)
题目链接: 1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MB Description 现在请求你维护一个数列,要 ...
- 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 ...
- 【bzoj1012】[JSOI2008]最大数maxnumber
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 8339 Solved: 3624[Submi ...
- [JSOI2008]最大数maxnumber
[JSOI2008]最大数maxnumber 标签: 线段树 单独队列 题目链接 题解 线段树裸题. 如果一直RE可能是你用的cin/cout. Code #include<cstdio> ...
随机推荐
- centos、mac的grafana安装和简单使用
1.安装: 参考官方文档安装说明:https://grafana.com/grafana/download Redhat & Centos(64 Bit): wget https://s3-u ...
- 运行计划中cost计算方法
概念: blevel:二元高度=索引高度-1 clustering_factor:集群因子,通过索引扫面得出的要查询table的blocks数量,clustering_factor接近table的bl ...
- 一起talk C栗子吧(第九十六回:C语言实例--使用共享内存进行进程间通信二)
各位看官们.大家好,上一回中咱们说的是使用共享内存进行进程间通信的样例,这一回咱们接着上一回内容继续说使用共享内存进行进程间通信. 闲话休提,言归正转.让我们一起talk C栗子吧! 我们在上一回中介 ...
- ZOJ 2706 Thermal Death of the Universe (线段树)
题目链接:ZOJ 2706 Thermal Death of the Universe (线段树) 题意:n个数.m个操作. 每一个操作(a,b)表示(a,b)全部值更新为这个区间的平均数:1.当前的 ...
- 【转载】HTTP POST GET SOAP本质区别详解
一 原理区别 一般在浏览器中输入网址访问资源都是通过GET方式:在FORM提交中,可以通过Method指定提交方式为GET或者POST,默认为GET提交 Http定义了与服务器交互的不同方法,最基本的 ...
- ArrayAdapter requires the resource ID to be a TextView
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABDUAAADFCAIAAADLz168AAAgAElEQVR4nO2d368kxZXnQ37dn9qdWa
- (1)JDBC基础-java链接mysql数据库
怎么操作数据库: 1,通过客户端(比如mac的终端,或者sql pro等专业工具)登陆数据库服务器(mysql -u root -p) 2,编写sql语句 3,发生sql语句到数据库服务器执行. JD ...
- css难点总结
1 margin 2 各种布局 3 各种垂直居中
- YTU 2900: F-A Simple Question
2900: F-A Simple Question 时间限制: 1 Sec 内存限制: 128 MB 提交: 66 解决: 24 题目描述 今天,pasher打算在一个浪漫的花园和他的搭档们聚餐, ...
- js的location对象
js的location对象 location基础知识 BOM(浏览器对象模型)中最有用的对象之一就是location,它是window对象和document对象的属性.location对象表示载入窗口 ...