#P6145. [USACO20FEB] Timeline G
[USACO20FEB] Timeline G
Description
Bessie has done milkings over the past days, but she has forgotten on which day each milking happened.
For the -th milking, Bessie remembers that it happened no earlier than day . Also, she has memories, each given as a triple , meaning that the -th milking happened at least days after the -th milking finished.
Now please help Bessie compute the earliest possible day for each milking while satisfying all conditions.
It is guaranteed that Bessie's memories are correct, which means there exists at least one valid schedule such that:
- The -th milking happens no earlier than day and no later than day .
- All memories are satisfied.
Input Format
The first line contains three integers . It is guaranteed that and .
The next line contains integers . It is guaranteed that for all , we have .
The next lines each contain three integers , describing one memory. It is guaranteed that and .
Output Format
Output lines, each containing one integer. The number on line is the earliest possible day of the -th milking.
4 10 3
1 2 3 4
1 2 5
2 4 2
3 4 4
1
6
3
8
Hint
- Test cases satisfy .
- Test cases have no special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号