#K58552. Effective Discount Campaigns

    ID: 30667 Type: Default 1000ms 256MiB

Effective Discount Campaigns

Effective Discount Campaigns

In this problem, you are given several discount campaigns. Each campaign is defined by a start date, an end date, and a discount percentage. On a given query date, the effective discount is the maximum discount percentage among all campaigns active on that day. A campaign is considered active if the query date is within its start and end dates (inclusive). If no campaign is active on that date, the effective discount is 0.

Formally, if the campaigns are given as a list of tuples ((s_i, e_i, d_i)) and a query date (Q), then the effective discount is computed as:
[ \text{effective_discount} = \max { d_i ;:; s_i \le Q \le e_i }] If no such (i) exists, the answer is 0.

inputFormat

The input is read from standard input and formatted as follows:

1. The first line contains an integer (n), which is the number of discount campaigns.
2. Each of the next (n) lines contains three items: start date, end date and discount percentage. The dates are in the format YYYY-MM-DD and the discount is an integer.
3. The last line contains the query date in the format YYYY-MM-DD.

outputFormat

Output a single integer to the standard output representing the effective discount percentage on the given date. If no campaign is active, output 0.## sample

3
2023-01-01 2023-01-10 15
2023-01-05 2023-01-12 20
2023-01-11 2023-01-20 10
2023-01-06
20