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

34445번 - Rent Division 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 2048 MB71251639.024%

문제

In an apartment just down the street from Colorado School of Mines, there are $N$ roommates who are trying to figure out how to pay their rent every month. These roommates also have other expenses that they share as well. Rather than using Venmo to share those expenses like sane individuals, they have decided to handle all money exchanges by paying different proportions of rent at the beginning of each month.

For example, let's say there are $N = 4$ roommates in an apartment: Jack, Joseph, Jordan, and David. Jack always pays the Internet and utility bills, totalling $\81ドル$ ($c_1$), while everyone else pays nothing ($c_2 = c_3 = c_4 = \0ドル$). Assuming rent this month is $\1963ドル$ ($R$), how much should each person pay (rounded up), so that each of their total contributions (including expenses that they have already paid) are equal and so that the entire rent is paid?

These roommates are entirely stumped because this is such a difficult calculation. Your mission, if you choose to accept it, is to aid these $N$ roommates in finding out what portion of the rent they need to pay individually. If it is not possible, then you should output "not possible", and everyone has to get Venmo. This happens if someone pays too much in other expenses and would need to be paid, rather than pay, rent.

입력

The first line consists of one integer, $N$ (1ドル \leq N \leq 100\ 000$) which is the number of roommates. The next $N$ lines each have one integer $c_i$ (0ドル \leq c_i \leq 10\ 000$) indicating how much person $i$ has paid on non-rent expenses.

The last line is the rent due this month, $R$ (0ドル \leq R \leq 500\ 000\ 000$).

출력

If it is not possible for the total contributions from each roommate to be equal, then output a single line with the words "not possible".

If it is possible for each of the $N$ roommates to make an equal total contribution, then output $N$ lines each with an integer, $p_i,ドル indicating how much of the rent the corresponding person, person $i,ドル should pay.

제한

예제 입력 1

4
81
0
0
0
1963

예제 출력 1

430
511
511
511

예제 입력 2

1
0
1

예제 출력 2

1

예제 입력 3

5
1000
0
0
0
0
100

예제 출력 3

not possible

노트

출처

School > CS@Mines > CS@Mines HSPC 2019 J번

  • 문제를 만든 사람: Joseph McKinsey
(追記) (追記ここまで)

출처

대학교 대회

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

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