#P7760. [COCI 2016/2017 #5] TUNA
[COCI 2016/2017 #5] TUNA
Description
A fisherman caught tuna last night. He plans to sell these fish to a platform.
For each fish, the platform provides two estimated values . If the difference between these two values is no more than , then the larger one is taken as the value of the fish. Otherwise, if the difference exceeds , then another value is taken.
Now you are given the values for fish (each fish may have or values). Find the total value of all fish.
Input Format
The first line contains an integer , the number of tuna.
The second line contains an integer .
The following lines are divided into parts, each describing one fish. Each part has one of the following two formats:
- The part consists of exactly one line containing two integers .
- The part consists of two lines: the first line contains two integers , and the second line contains one integer .
Output Format
Output the total value of all fish.
5
2
3 4
2 1
5 3
4 4
4 2
19
4
2
3 5
2 8
4
6 5
6 3
7
22
3
10
20 50
30
20 40
50
70 20
10
90
Hint
Sample 2 Explanation.
The fisherman caught tuna, and the value of is :
| Tuna ID | Difference | Final value | |||
|---|---|---|---|---|---|
| / | |||||
| / | |||||
So the total value is .
Constraints.
For of the testdata, , , .
Notes.
Translated from COCI 2016-2017 CONTEST #5 T1 Tuna.
The score of this problem follows the original COCI problem, with a full score of .
Translated by ChatGPT 5
京公网安备 11011102002149号