#SRD0000050. Nhảy qua các ngọn đồi (Hill Jumping)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Nhảy qua các ngọn đồi (Hill Jumping)
Hill Jumping
Source: CodeChef
Version: Phuoc Hung OJ Extended
Problem Statement
There are hills of heights . From hill , a participant jumps to the nearest strictly higher hill to the right, provided its index distance is at most . If no such hill exists, all remaining jumps leave the participant in place.
Process:
1 i k: report the final hill after up to prescribed jumps from hill .2 L R X: add the integer (possibly negative) to all hill heights in the inclusive interval.
All jump queries use the current heights.
Input
The first line contains , followed by the initial heights. Each operation is 1 i k or 2 L R X; and .
Output
Print the final hill index for every type-1 query.
Subtasks
- Subtask 1 (20 points): ; . The original 20%/80% scoring split; each jump may inspect at most the next 100 positions.
- Subtask 2 (80 points): ; . The original 20%/80% scoring split; each jump may inspect at most the next 100 positions.
Examples
Input
5 3
1 2 3 4 5
1 1 2
2 3 4 -1
1 1 2
Output
3
4
Explanation
The first query jumps from hill to hill and then hill , yielding 3. After subtracting one from hills and , heights become . From hill , the participant reaches , skips equally high hill , and reaches hill , yielding 4.