PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000041. Khoảng cách giữa giá trị bằng nhau
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Khoảng cách giữa giá trị bằng nhau
GukiZ and GukiZiana
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array , handle:
1 l r x: increase all values in by non-negative .2 y: find the maximum distance between two positions with . Output-1if does not occur.
If occurs exactly once, the answer is . Values may be changed by multiple overlapping updates.
Input
The first line contains , the next the initial array, followed by lines of 1 l r x or 2 y.
Output
Print one integer for each query of type 2 y.
Subtasks
- Subtask 1 (10 points): ; ; ; .
- Subtask 2 (20 points): ; ; ; .
- Subtask 3 (30 points): ; ; ; .
- Subtask 4 (40 points): ; ; ; .
Examples
Input
4 3
1 2 3 4
1 1 2 1
1 1 1 1
2 3
Output
2
Explanation
After adding on positions and then on position , the array becomes . Value appears from position to position , giving distance .