Logo
(追記) (追記ここまで)

18780번 - Timeline 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB53228724354.241%

문제

Bessie attended $N$ milking sessions (1ドル\le N\le 10^5$) over the past $M$ days (2ドル \le M \le 10^9$). However, she is having trouble remembering when she attended each session.

For each session $i = 1 \ldots N,ドル she knows that it occurred no earlier than day $S_i$ (1ドル\le S_i\le M$). Additionally, Bessie has $C$ memories (1ドル\le C\le 10^5$), each described by a triple $(a,b,x),ドル where she recalls that session $b$ happened at least $x$ days after $a$.

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 1ドル\ldots M$ such that all constraints from her memories are satisfied.

입력

The first line of input contains $N,ドル $M,ドル and $C$.

The next line contains $N$ space-separated integers $S_1,S_2,\ldots, S_N$. Each is in the range 1ドル \ldots M$.

The next $C$ lines contain three integers, $a,ドル $b,ドル and $x$ indicating that session $b$ happened at least $x$ days after $a$. For each line, $a \neq b,ドル $a$ and $b$ are in the range 1ドル \ldots N,ドル and $x$ is in the range 1ドル \ldots M$.

출력

Output $N$ 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

힌트

Session two occurred at least five days after session one, so it cannot have occurred before day 1ドル+5=6.$ Session four occurred at least two days after session two, so it cannot have occurred before day 6ドル+2=8$.

출처

Olympiad > USA Computing Olympiad > 2019-2020 Season > USACO 2020 February Contest > Gold 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /