PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000243. Nhiệt độ pha cà phê (Karen and Coffee)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nhiệt độ pha cà phê (Karen and Coffee)
Karen and Coffee
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Each of coffee recipes recommends every integer temperature in its inclusive interval . A temperature qualifies if at least recipes recommend it. For each inclusive query , count qualifying integer temperatures in that interval.
Input
First line: . The next lines contain , followed by lines containing .
Output
Print one integer per query, on a separate line.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Example 1
Input
3 2 4
91 94
92 97
97 99
92 94
93 97
95 96
90 100
Output
3
3
0
4
Explanation
The qualifying temperatures are 92, 93, 94, 97; intersections yield 3,3,0,4.
Example 2
Input
2 1 1
1 1
200000 200000
90 100
Output
0
Explanation
Neither 1 nor 200000 belongs to [90,100].