RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00250

Akvarij

Unrated 레이팅 미적용
난이도
1s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(4^{th}\) round, January \(19^{th}\), 2013

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-co\)ordinate of 0, and the right wall
has the \(x-co\)ordinate of \(N - 1\). Each integ\(er-va\)lued \(x-co\)ordinate of the aquarium bottom (let us denote
it by i) from 0 to \(N - 1\) has a separately adjustable height of H_{i}. Between any two adjacent integer-
valued \(x-co\)ordinates i and \(i + 1\), the bottom can be described by a line segment between points (i, H_{i})
and (\(i + 1\), H_{i}_{+ 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 \le N \le 100\,000\), the length of the bottom)
and M (\(1 \le M \le 100\,000\), the number of queries).
The second line of input contains N spa\(ce-se\)parated nonnegative integers H_{i} (\(0 \le H_{i} \le 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 \le h \le 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-co\)ordinate i (\(0 \le i \le N - 1\)) to h (\(0 \le h\)
1000); in other words, set \(H_{i} = 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.

\(4^{th}\) round, January \(19^{th}\), 2013

예제 1
입력
3 2
20 20 20
Q 20
Q 30
출력
0.000
20.000
예제 2
입력
3 5
0 2 0
Q 2
U 1 1
Q 1
U 1 10
Q 5
출력
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
출력
0.750
3.750
9.000
1.500
6.000
12.000
설명

Clarification of the third example: The left image below shows the situation before, and the right
one after the U-type query, for water level h = 2 (query Q 2). In the first image, the submerged area
equals 3.75, and in the second image it is 6.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2012/2013 Contest 4

평가 및 의견

Akvarij

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Akvarij

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8