PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#TP0000077. MEX so với trung vị (MEX vs MED)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
MEX so với trung vị (MEX vs MED)
MEX vs MED
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a permutation of , count nonempty contiguous segments whose mex is strictly greater than the lower median (the -th sorted element).
Input
Line 1: . Line 2: permutation . Exactly one case, no .
Output
Print the 64-bit count of valid segments.
Subtasks
- Subtask 1 (20 points): Exactly one dataset; ; the sequence is a permutation of .
- Subtask 2 (30 points): Exactly one dataset; ; the sequence is a permutation of .
- Subtask 3 (50 points): Exactly one dataset; ; the sequence is a permutation of .
Example
Input
3
1 0 2
Output
4
Explanation
Four subsegments have mex greater than the lower median.