문제
Bessie attended milking sessions () over the past days (). However, she is having trouble remembering when she attended each session.
For each session , she knows that it occurred no earlier than day (). Additionally, Bessie has memories (), each described by a triple , where she recalls that session happened at least days after .
Help Bessie by computing the earliest possible date of occurrence for each milking session. It is guaranteed that Bessie did not remember incorrectly; in other words, there exists an assignment of sessions to days in the range such that all constraints from her memories are satisfied.
SCORING: Test cases 2-4 satisfy .Test cases 5-10 satisfy no additional constraints.
입력
The first line of input contains , , and .
The next line contains space-separated integers . Each is in the range .
The next lines contain three integers, , , and indicating that session happened at least days after . For each line, , and are in the range , and is in the range .
출력
Output lines giving the earliest possible date of occurrence for each session.
예제 입력 1
4 10 3
1 2 3 4
1 2 5
2 4 2
3 4 4
예제 출력 1
1
6
3
8
코드를 제출하려면 로그인이 필요합니다.
로그인