PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FT0000124. Các cặp tập phim dễ nhầm lẫn (Tufurama)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Các cặp tập phim dễ nhầm lẫn (Tufurama)
Tufurama
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A TV series has seasons numbered to . Season has episodes numbered to .
An unordered pair of distinct seasons , with , is confusing if both season , episode , and season , episode exist. Equivalently, and must hold simultaneously.
Count all such pairs, each exactly once.
Input
- First line: (seasons).
- Second line: positive integers .
Output
Print the number of season pairs with for which both corresponding episodes exist.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Example 1
Input
3
8 12 7
Output
3
Explanation
Valid season pairs: (1,2), (1,3), (2,3). Each pair meets both episode-existence conditions. 3 pairs.
Example 2
Input
3
3 2 1
Output
2
Explanation
Valid season pairs: (1,2), (1,3). Each pair meets both episode-existence conditions. 2 pairs.