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

Mountain

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

의견: 0

설명

Task: MOU
Mountain
Saturday, 20–08–2005
Available memory: 256 MB. Maximum running time: 3 s.
The Mountain Amusement Park has opened a brand-new simulated roller coaster. The simulated track con-
sists of n rails attached end-to-end with the beginning of the first rail fixed at elevation 0. Byteman, the
operator, can reconfigure the track at will by adjusting the elevation change over a number of consecutive
rails. The elevation change over other rails is not affected. Each time rails are adjusted, the following track is
raised or lowered as necessary to connect the track while maintaining the start at elevation 0. The figure on
the next page illustrates two example track reconfigurations.
Each ride is initiated by launching the car with sufficient energy to reach height h. That is, the car will
continue to travel as long as the elevation of the track does not exceed h, and as long as the end of the track
is not reached.
Given the record for all the day’s rides and track configuration changes, compute for each ride the number
of rails traversed by the car before it stops.
Internally, the simulator represents the track as a sequence of n elevation changes, one for each rail. The
i-th number di represents the elevation change (in centimetres) over the i-th rail. Suppose that after traversing
i−1 rails the car has reached an elevation of h centimetres. After traversing i rails the car will have reached
an elevation of h +di centimetres.
Initially the rails are horizontal; that is, di = 0 for all i. Rides and reconfigurations are interleaved through-
out the day. Each reconfiguration is specified by three numbers: a, b and D. The segment to be adjusted
consists of rails a through b (inclusive). The elevation change over each rail in the segment is set to D. That
is, di = D for all a ≤i ≤b.
Each ride is specified by one number h — the maximum height that the car can reach.
Task
Write a program that:
• reads from the standard input a sequence of interleaved reconfigurations and rides,
• for each ride computes the number of rails traversed by the car,
• writes the results to the standard output.

Example

For the input data:
4
Q 1
I 1 4 2
Q 3
Q 1
I 2 2 -1
Q 3
E
the correct result is:
4
1
0
3
0
1
2
3
2
0
1
2
3
4
5
6
2
7
8
2
2
2
4
6
8
0
0
0
0
0
0
0
0
2
1
3
5
0
1
2
3
4
5
6
2
−1
2
2
1
2
3
4
1
2
3
4
1
2
3
4
Views of the track before and after each reconfiguration. The x axis denotes the rail number. The y axis and
the numbers over points denote elevation. The numbers over segments denote elevation changes.
v. 1.04
2/2
Mountain

Note (RiseOJ) — The original statement describes file-based input/output; on this judge your program must read from standard input and write to standard output instead.

제약
입력 형식

The first line of input contains one positive integer n — the number of rails, 1 ≤n ≤1000000000. The
following lines contain reconfigurations interleaved with rides, followed by an end marker. Each line contains
one of:
• Reconfiguration — a single letter ‘I’, and integers a,b and D, all separated by single spaces (1 ≤a ≤
b ≤n, −1000000000 ≤D ≤1000000000).
• Ride — a single letter ‘Q’, and an integer h (0 ≤h ≤1000000000) separated by a single space;
v. 1.04
½
Mountain

• A single letter ‘E’ — the end marker, indicating the end of the input data.
You may assume that at any moment the elevation of any point in the track is in the interval [0,1000000000]
centimetres. The input contains no more than 100000 lines.
In 50 % of test cases n satisfies 1 ≤n ≤20000 and there are no more than 1000 lines of input.

출력 형식

The i-th line of output should consist of one integer — the number of rails traversed by the car during the i-th
ride.

문제 정보

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

출처 IOI 2005

평가 및 의견

Mountain

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

Log in to rate problems.

개별 의견

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

풀이 제출

Mountain

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