单点更新,区间求最大值的题;

可以使用树状数组和线段树;

#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 2000009
#define ll long long
using namespace std; int m,n=;
ll ma[maxn],d[maxn]; void insert(int w,ll x)
{
d[w]=x;
while(w<=m)
{
ma[w]=max(ma[w],x);
w+=w&-w;
}
} ll query(int l,int r)
{
ll ret=d[r];
while(l<=r)
{
int cnt=r&-r;
ret=max(ret,d[r]);
if(r-cnt+>=l)
{
ret=max(ret,ma[r]);
r-=r&-r;
}
else r--;
}
return ret;
} char s[];
ll x,mod; int main()
{
ll t=;
scanf("%d%lld",&m,&mod);
for(int i=;i<m;i++)
{
scanf("%s",s);
if(s[]=='A')
{
scanf("%d",&x);
++n;
insert(n,(x+t)%mod);
}
else
{
scanf("%d",&x);
t=query(n-x+,n);
printf("%lld\n",t);
}
}
return ;
}

1012: [JSOI2008]最大数maxnumber的更多相关文章

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

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

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

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

  3. BZOJ 1012: [JSOI2008]最大数maxnumber 单调队列/线段树/树状数组/乱搞

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

  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. BZOJ——1012: [JSOI2008]最大数maxnumber || 洛谷—— P1198 [JSOI2008]最大数

    http://www.lydsy.com/JudgeOnline/problem.php?id=1012|| https://www.luogu.org/problem/show?pid=1198 T ...

  7. 【BZOJ】1012: [JSOI2008]最大数maxnumber(树状数组+rmq)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1012 树状数组原来我只懂得sum和add的操作,今天才知道可以有求区间最值的操作,我学习了一下写了个 ...

  8. bzoj 1012 [JSOI2008]最大数maxnumber

    原题链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1012 线段树,单点更新.. #include<algorithm> #incl ...

  9. BZOJ 1012: [JSOI2008]最大数maxnumber 线段树

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1012 现在请求你维护一个数列,要求提供以下两种操作: 1. 查询操作.语法:Q L 功能: ...

  10. 【BZOJ】1012: [JSOI2008]最大数maxnumber 树状数组求区间最值

    题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1012 题意:维护一个数列,开始时没有数值,之后会有两种操作, Q L :查询数列末 ...

随机推荐

  1. JS完美运动框架

    这套框架实现了多物体,任意值,链式运动,多值运动,基本满足常见的需求. /* 功能:完美运动框架,可以实现多物体,任意值,链式运动,多值运动 版本:V1.0 兼容性:Chrome,FF,IE8+ (o ...

  2. 聊聊css盒子模型

    css盒子模型原理: 在网页设计中常听的属性名:内容(content).填充/内边距(padding).边框(border).外边距(margin), CSS盒子模式都具备这些属性. 这些属性我们可以 ...

  3. .net 并发

    Nhibernate并发参考 http://www.cnblogs.com/lyj/archive/2008/10/21/1316269.html EF并发参考 http://www.cnblogs. ...

  4. ACM——五位以内的对称素数

    http://acm.njupt.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1026 五位以内的对称素数 时间限制(普 ...

  5. 数据库笔试题(经典select语句的用法)【转载】

    原文地址:数据库笔试题(经典select语句的用法)作者:lily 问题描述: 为管理岗位业务培训信息,建立3个表: S (S#,SN,SD,SA) S#,SN,SD,SA 分别代表学号.学员姓名.所 ...

  6. Objective-C 【self的用法】

    ------------------------------------------- self和super关键字 OC提供了两个保留字self和super,用于在方法定义中引用该执行方法的对象. O ...

  7. The method getContextPath() is undefined for the type ServletContext

    我出错时,到网上说得是版本问题,我找到对应的包javax-servlet5.1.12.jar,把它删了,居然不报错了,原来是和包servlet-2_5-api.jar冲突了

  8. fsockopen/curl/file_get_contents效率比较

    前面小节 PHP抓取网络数据的6种常见方法 谈到了 fsockopen,curl与file_get_contents 的使用方法,虽然它们都能达到同一个使用目的,但是它们之间又有什么区别呢? 先谈谈c ...

  9. Eclipse配置CAS server

    1.下载cas server的源码包(我使用的是cas-server-3.5.2.1-release.zip) 2.解压压缩包到某个目录下,找到cas-server-3.5.2.1-release.z ...

  10. 出力csv

    public static void ExportResultLog(System.Data.DataTable dt, string fileName, string path) { if (!Sy ...