#P15452. [JOI 2026 SemiFinal] 宝石商 / Jeweler
[JOI 2026 SemiFinal] 宝石商 / Jeweler
Problem Description
JOI runs a jewelry shop. There are customers who want to buy jewels, numbered from to . Customer () can visit the shop at any time between time and time , and plans to buy jewels.
JOI is very busy and cannot keep the shop open all the time. Therefore, he considers possible opening-time plans. The plans are numbered from to , and plan () means the shop is open from time to time . For each plan, customer () will visit the shop and buy jewels if there exists a time when the shop is open within the time interval in which they can visit. Otherwise, if no such time exists, customer will not visit and will not buy any jewels. However, JOI’s shop has enough jewels, so it will never run out.
Given the customer information and each opening-time plan, write a program to compute, for each plan, the total number of jewels that can be sold.
Input Format
The input is given from standard input in the following format:
Output Format
Output lines to standard output. On the -th line (), output the total number of jewels that can be sold under plan .
3
3 4 10
5 8 20
6 10 30
3
4 6
1 2
6 8
60
0
50
4
10 90 1
40 60 2
10 20 4
80 90 8
3
1 15
1 60
1 100
5
7
15
10
55 882 861052753
104 734 331227764
492 694 240198464
481 506 377367203
131 185 327968773
124 129 970226535
92 125 133053911
356 442 758055457
21 759 730522637
259 481 948997757
9
50 287
510 735
158 431
113 768
328 894
783 881
163 692
42 862
43 752
4303050130
2163001618
3957825141
5678671254
4247422035
861052753
4575390808
5678671254
5678671254
Hint
Sample Explanation 1
In plan 1, the shop is open from time to time . Customer 1 can come at time , customer 2 can come at time , and customer 3 can come at time to buy jewels. In total, jewels are sold.
In plan 2, the shop is open from time to time . No customer can visit during the opening time, so a total of jewels are sold.
In plan 3, the shop is open from time to time . Customers 2 and 3 can both come at time to buy jewels. In total, jewels are sold.
This sample input satisfies the constraints for subtasks 1 and 5.
Sample Explanation 2
In plan 1, customers 1 and 3 can visit the shop to buy jewels. In total, jewels are sold.
In plan 2, customers 1, 2, and 3 can visit the shop to buy jewels. In total, jewels are sold.
In plan 3, all customers can visit the shop to buy jewels. In total, jewels are sold.
This sample input satisfies the constraints for subtasks 1, 3, 4, and 5.
Constraints
- ()
- ()
- ()
- All input values are integers.
Subtasks
- (12 points)
- (17 points) ()
- (21 points) ()
- (23 points) ()
- (27 points) No additional constraints.
Translated by DeepSeek.
Translated by ChatGPT 5