RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 R03730

Izbori

설명

It is election time. V voters attend the election, each casting their vote for one of N political parties. M
officials will be elected into the parliament.
The conversion from votes to parliament seats is done using the D'Hondt method with a 5% threshold.
More precisely, suppose that the parties are numbered 1 through N and that they receive \(V_{1}\), \(V_{2}\), ..., \(V_{N}\)
votes. Parliament seats are allocated as follows:
1. All parties that receive strictly less than 5% of V votes are erased from the list of parties.
2. The parliament is initially empty i.e. every party has zero seats allocated.
3. For each party P, the quotient \(Q_{P}=V_{P}\)/(\(S_{P}+1\)) is calculated, where \(V_{P}\) is the total number of
votes received by party P, and \(S_{P}\) is the number of seats already allocated to party P.
4. The party with the largest quotient \(Q_{P}\) is allocated one seat. If multiple parties have the same
largest quotient, the lower numbered party wins the seat.
5. Repeat steps 3 and 4 until the parliament is full.
The votes are being counted and only part of the V votes has been tallied. It is known how many votes
each party has received so far.
Write a program that calculates for each party, among all possible outcomes of the election after all V
votes are counted, the largest and smallest number of seats the party wins.

제약

For each test case, the two subtasks (two lines of output) are scored independently.
Solving the first subtask correctly is worth 20% of points.
Solving the second subtask correctly is worth 80% of points. It is necessary to output exactly N integers
on the first line (even if they are completely wrong) for the second subtask to be graded.

입력 형식

The first line contains the integers V, N and M (\(1 \le V \le 10\),000,000, \(1 \le N \le 100\), \(1 \le M \le 200\)), the
numbers of votes, parties and seats in the parliament.
The second line contains N integers – how many votes (of those that have been counted) each party
got. The sum of these numbers will be at most V.

출력 형식

On the first line output N integers separated by spaces – the largest number of seats each party can
win.
On the second line output N integers separated by spaces – the smallest number of seats each party can
win.

예제 1
입력
20 4 5
4 3 6 1
출력
3 3 3 2
1 0 1 0
예제 2
입력
100 3 5
30 20 10
출력
4 3 3
1 1 0
In the first example, 14 votes have been tallied and 6 are yet to be counted. To illustrate one possible
outcome, suppose that the first party receives 2 of those 6 votes, the second none, the third 1 vote and
the fourth 3 votes. The parties' totals are 6, 3, 7 and 4 votes. All parties exceeded the 5% threshold.
Seats are allocated as follows:
1. The quotients are initially 6/1, 3/1, 7/1 and 4/1; the largest is 7/1 so party 3 wins a seat.
2. The quotients are 6/1, 3/1, 7/2 and 4/1; the largest is 6/1 so party 1 wins a seat.
3. The quotients are 6/2, 3/1, 7/2 and 4/1; the largest is 4/1 so party 4 wins a seat.
4. The quotients are 6/2, 3/1, 7/2 and 4/2; the largest is 7/2 so party 3 wins a seat.
5. The quotients are 6/2, 3/1, 7/3 and 4/2; parties 1 and 2 are tied with quotients 6/2 and 3/1,
but party 1 is lower numbered so it wins the last seat.
In this outcome, the numbers of seats won by the parties are 2, 0, 2 and 1. Since it is possible for the
second party not to win any seats, the second number on the second line of output is zero.
문제 정보

생성자가 기록되지 않았습니다.

출처 COI 2009

평가 및 의견

Izbori

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Izbori

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8