#1098
Unrated
AKVARIJ
시간 제한
1s
메모리 제한
256MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Gustav Matula

Mirko has recently installed a new screensaver. If he is away from the keyboard for five minutes, the screen shows a picture of an aquarium with animated fish. The screensaver has settings for customizing the shape of the (virtual, sandy) aquarium bottom, as well as the water level. The aquarium can be represented in a 2D Cartesian coordinate system as a shape N - 1 columns wide, where N is a positive integer. The left wall of the aquarium has the x-coordinate of 0, and the right wall has the x-coordinate of N - 1. Each integer-valued x-coordinate of the aquarium bottom (let us denote it by i) from 0 to N - 1 has a separately adjustable height of Hi. Between any two adjacent integer- valued x-coordinates i and i + 1, the bottom can be described by a line segment between points (i, Hi) and (i + 1, Hi + 1). If the water level is set to h, the water fills the area between the line y = h and the aquarium bottom. If a part of the aquarium bottom is above the water level h, it forms an island and is not submerged. For different shapes of the aquarium bottom, Mirko would like to know the total area of his screen covered by water. Help Mirko find answers to his questions (other than 42).

입력

The first line of input contains two positive integers, N (3 ≤ N ≤ 100 000, the length of the bottom) and M (1 ≤ M ≤ 100 000, the number of queries). The second line of input contains N space-separated nonnegative integers Hi (0 ≤ Hi ≤ 1000), the starting bottom heights. Each of the following M lines contains a single query with one of the following two types: Q h – if the water level is set to h (0 ≤ h ≤ 1000), assuming the current bottom shape, what is the total screen area covered by water? U i h – Mirko has decided to change the bottom height at x-coordinate i (0 ≤ i ≤ N - 1) to h (0 ≤ h ≤ 1000); in other words, set Hi = h.

출력

For each query with type Q, output a single line containing the required area, rounded to exactly three decimals. The area given is allowed to differ by at most 0.001 from the official solution. Author: Gustav Matula

예제 입력 1

3 2
20 20 20
Q 20
Q 30

예제 출력 1

0.000
20.000

예제 입력 2

3 5
0 2 0
Q 2
U 1 1
Q 1
U 1 10
Q 5

예제 출력 2

2.000
1.000
2.500

예제 입력 3

7 7
0 2 1 3 2 1 0
Q 1
Q 2
Q 3
U 3 0
Q 1
Q 2
Q 3

예제 출력 3

0.750
3.750
9.000
1.500
6.000
12.000
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.