_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> ...
随机推荐
- 【转载】epoll与select/poll的区别总结
因为这道题目经常被问到.干脆总结一下,免得遗漏了. 参考文章:http://www.cnblogs.com/qiaoconglovelife/p/5735936.html 1 本质上都是同步I/O 三 ...
- MAC上反编译android apk---apktool, dex2jar, jd-jui安装使用(含手动签名)
前文 介绍了在Windows平台利用强大的APK-Multi-Tool进行反编译apk,修改smali源码后再回编译成apk的流程,最近受人之托,破解个apk,所幸的是所用到的这三个软件都是跨平台的, ...
- 【stl学习笔记】set、multiset
set和multiset会根据特定的排序准则,自动将元素排序.两者不同处在于multiset允许元素重复而set不允许 在使用set或multiset之前,必须先加入头文件<set> se ...
- 静态网页怎样实现动态交互?-JavaScript
在Html基础上,javascript能够开发交互式web网页.javascript的出现使得网页和用户之间实现了一种实时性的.动态的.交互性的关系,javascript短小精悍,又是在客户机上执行的 ...
- [Analytics] Add Tealium debugger in Chrome
It would be helpful once you can see what information have been tracking inside you web application, ...
- hdu1181 dfs搜索之变形课
原题地址 这道题数据据说比較水,除了第一组数据是Yes以外.其余都是No.非常多人抓住这点就水过了.当然了,我认为那样过了也没什么意思.刷oj刷的是质量不是数量. 这道题从题目上来看是个不错的 搜索题 ...
- JAVA_the user operation is waiting怎么办
彻底解决 MyEclipse出现the user operation is waiting的问题 2011-05-31 10:32:30| 分类: 软件编程 | 标签:java myecli ...
- VS code - code Snippet
For anyone working on the UI and using VS Code, you can create a user Snippet and keyboard shortcut ...
- spring的PROPAGATION_REQUIRES_NEW事务,下列说法正确的是(D)
A:内部事务回滚会导致外部事务回滚 B:内部事务回滚了,外部事务仍可以提交 C:外部事务回滚了,内部事务也跟着回滚 D:外部事务回滚了,内部事务仍可以提交 PROPAGATION_REQUIRES_N ...
- 请说出作用域public,private,protected,以及不写时的区别
这四个作用域的可见范围如下表所示. 说明:如果在修饰的元素上面没有写任何访问修饰符,则表示friendly. 作用域 当前类 同一package 子孙类 其他package public ...