QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#4141. 体育课

الإحصائيات

又是一节体育课的时间了,有 $n$ 个同学排成了一排。他们都很讨厌排在第一个位置的同学,于是后面的同学中比第一个高的都会产生一个高兴值,这个高兴值等于他的身高减去第一个同学的身高。当然比第一个同学矮的同学产生兴奋值为 $0$。

现在体育老师来了,他拥有神奇的魔法,现在他能做如下的三件事:

  1. 询问某段区间高兴值最大的那个是多少
  2. 把某两个同学交换一下位置
  3. 选取一段区间的人,把第一个人身高加上 $t$,第二个加上 $2t$,第三个加上 $3t$ 以此类推

但是体育老师不会数数,于是他找到你了,对于每一个询问,他要你帮他求出那个值。

输入格式

第一行两个整数 $n,m$,表示有 $n$ 个人,有 $m$ 个操作。

第二行 $n$ 个整数,顺序输入每个人的身高 $a_i$。

接下来 $m$ 行,每行第一个数为一个 $type$ 表示是做哪一件事情。

  • 如果 $type=1$,那么接下来有两个整数 $l,r$,表示询问这段区间的最大的高兴值
  • 如果 $type=2$,接下来两个整数 $a,b$,表示交换这两个位置的人
  • 如果 $type=3$,接下来三个整数 $l,r,t$,表示把 $l$ 个人的升高增加 $t$,$l+1$ 个人增加 $2t$ ...第 $r$ 个人增加 $(r-l+1)t$

输出格式

对于每个询问按照顺序输出每个操作 $1$ 的答案。

样例数据

样例输入

6 7
109 827 100 530 10 826
3 1 6 1
2 2 6
1 2 4
1 2 3
2 2 6
1 2 6
1 2 5

样例输出

722
722
722
719

子任务

  • 对于 $20\%$ 的数据,保证 $1 \le n,m \le 5 \times 10^3$
  • 另有 $10\%$ 的数据,没有第三种操作
  • 另有 $20\%$ 的数据,没有第二种操作
  • 对于 $100\%$ 的数据,$1 \le n,m \le 10^5$,$0 \le t \le 10^4$,$1 \leq a_i \leq 10^8$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.