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

25220번 - Rainy Markets 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 1024 MB135352732.927%

문제

There are $N$ covered bus shelters, labelled 1,ドル \ldots, N$. The $i^\text{th}$ bus shelter can fit $B_i$ people inside.

For each $i \in \{1, \ldots, N - 1\},ドル there is a sidewalk connecting bus shelter $i$ to bus shelter $i + 1,ドル with an open-air market in the middle. The $i^\text{th}$ market has $U_i$ umbrellas for sale, each costing $\1ドル$.

Right now, the $i^\text{th}$ market has $P_i$ people inside, and every person is in a market so all the bus shelters are empty.

Suddenly, it starts raining, and everyone at market $i$ has to decide between three possibilities:

  • to go to bus shelter $i$;
  • to go to bus shelter $i + 1$; or
  • to stay and buy an umbrella.

If a person is unable to find a place in a bus shelter or buy an umbrella, they will get wet.

If everyone coordinates optimally, can they all stay dry? If so, what is the least amount of money they need to spend, and which bus shelter should each person move to?

입력

The first line of input contains an integer $N$.

The second line of input contains $N$ space-separated integers $B_i$ $(1 \le i \le N),ドル the capacity of bus shelter $i$.

The third line of input contains $N - 1$ space-separated integers $P_i$ $(1 \le i \le N - 1),ドル the number of people at market $i$.

The fourth line of input contains $N - 1$ space-separated integers $U_i$ $(1 \le i \le N - 1),ドル the number of umbrellas for sale at market $i$.

출력

If every person can stay dry either under an umbrella or at a bus shelter, the output will be $N + 1$ lines:

  • the first line will contain the word YES.
  • the second line will contain the least amount of money necessary to spend on umbrellas
  • the next $N - 1$ lines will each contain three space-separated integers:
    • the number of people at market $i$ moving to bus shelter $i$
    • the number of people at market $i$ buying an umbrella
    • the number of people at market $i$ moving to bus shelter $i + 1,ドル where 1ドル \le i \le N - 1$.

If not every person can stay dry, the output will be one line containing the word NO.

If there are multiple possible correct outputs, any correct output will be accepted.

제한

서브태스크

번호배점제한
15

2ドル \le N \le 10^6,ドル 0ドル \le B_i \le 2 \cdot 10^9,ドル 0ドル \le P_i \le 10^9,ドル $U_i = 0$

25

2ドル \le N \le 2,000円,ドル 0ドル \le B_i \le 400,ドル 0ドル \le P_i \le 200,ドル 0ドル \le U_i \le 200$

36

2ドル \le N \le 4,000円,ドル 0ドル \le B_i \le 4,000円,ドル 0ドル \le P_i \le 2,000円,ドル 0ドル \le U_i \le 2,000円$

49

2ドル \le N \le 10^6,ドル 0ドル \le B_i \le 2 \cdot 10^9,ドル 0ドル \le P_i \le 10^9,ドル 0ドル \le U_i \le 10^9$

예제 입력 1

3
10 15 10
20 20
0 0

예제 출력 1

NO

There are 35ドル$ spots available at bus shelters and no umbrellas available, but there are 40ドル$ people in the markets.

예제 입력 2

3
10 15 10
20 20
0 11

예제 출력 2

YES
5
10 0 10
5 5 10

Looking at market 1ドル,ドル 10ドル$ people will go to bus shelter 1ドル,ドル no one will buy an umbrella, and 10ドル$ people will go to bus shelter 2ドル$.

Looking at market 2ドル,ドル 5ドル$ people will go to bus shelter 2ドル,ドル 5ドル$ people will stay and buy an umbrella, and 10ドル$ people will move to bus shelter 3ドル$.

In total, 5ドル$ umbrellas were purchased, which costs $\5ドル$.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2022 > CCO 2022 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

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

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