题目链接

ac代码(注意字符读入前需要注意回车的影响)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define mp make_pair
#define pi acos(-1)
#define pii pair<int, int>
#define pll pair<long long , long long>
#define ll long long
#define ld long double
#define MEMS(x) memset(x, -1, sizeof(x))
#define MEM(x) memset(x, 0, sizeof(x))
const int inf = 0x3f3f3f3f;
const int maxn = 200005;
using namespace std;
int N, M;
int s, c[maxn], d[maxn];
char order;
int lowbit(int x)
{
return x & (-x);
}
void update(int x)
{
while(x <= N)
{
d[x] = c[x];
int lx = lowbit(x);
for(int i = 1; i < lx; i <<= 1)
d[x] = max(d[x], d[x - i]);
x += lowbit(x);
}
}
int getmax(int l, int r)
{
int ans = 0;
while(r >= l)
{
ans = max(ans, c[r]);
--r;
while(r - lowbit(r) >= l)
{
ans = max(ans, d[r]);
r -= lowbit(r);
}
}
return ans;
}
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
while(scanf("%d %d", &N, &M) != EOF)
{
memset(d, 0, sizeof(d));
for(int i = 1; i <= N; i++)
{
scanf("%d", &c[i]);
update(i);
}
int a, b;
while(M--)
{
getchar();
scanf("%c %d %d", &order, &a, &b);
if(order == 'U')
{
c[a] = b;
update(a);
}
else if(order == 'Q')
printf("%d\n", getmax(a, b));
}
}
}

最新文章

  1. linux Mint wine安装qq,桌面快捷键配置
  2. 【leetcode】ZigZag Conversion
  3. MSBuild 中的 PropertyGroup、ItemGroup 和 ItemMetadata
  4. LoadScript
  5. SalesForce 入门
  6. Linux的sed命令
  7. Linux怎么使用添加的新硬盘
  8. python+webdriver ppt
  9. ionic项目的一些简单操作
  10. SQL 存储过程 执行效率优化提升 (显示估计)
  11. 快递查询api(多接口方案)
  12. webservice 的权限验证
  13. [Swift]LeetCode566. 重塑矩阵 | Reshape the Matrix
  14. Pycharm搭建Django开发环境
  15. 分布式计算课程补充笔记 part 2
  16. TCP和UDP的区别和优缺点
  17. 关于 redis、memcache、mongoDB 的对比 转
  18. Oracle数据库使用mybatis的时候,实体类日期为Date类型,mybatis里面定义的是Date类型,插入的时候,时分秒全部是12:00:00问题
  19. PostgreSQL存储过程(4)-return语句
  20. jQuery轮播图(手动点击轮播)

热门文章

  1. HLS协议
  2. Docker基础内容之端口映射
  3. convertto-securestring结果 使用python解密
  4. linux下面误删root里面的文件夹 恢复方法
  5. C语言笔记--传递结构指针以及值传递,址传递
  6. 《Head first设计模式》之单例模式
  7. javascript 动态加载javascript文件
  8. python3 jenkins api操作
  9. k8s pod时区更改
  10. 解析如何防止XSS跨站脚本攻击