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

D'Hondt

Silver II 실버 II
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

In the beginning of December, parliamentary elections were held in our country. Croatia is divided in \(10\) election regions. From each region, \(14\) parliamentary representatives are elected. Each of the voters is voting for one of the few parties. After voting, the representatives are elected using the D'Hondt (D"Ont) method.

By this method, first we select parties which gathered at least \(5\%\) of the votes. Number of votes of each of the selected parties is then divided by every number from \(1\) to \(14\). In this way we assign \(14\) rational numbers — let's call them 'scores' — to each of the parties.

First of the \(14\) representatives in a region is chosen from a party with the largest score. Second representative is selected from a party with the second largest score. The third... This procedure continues until all of the \(14\) places are elected. Remark: There will always be a unique way to elect the representatives, i.e. no two scores will be equal.

Write a program that, given the total number of voters and number of votes each party gained, determines how many politicians were elected as region representatives from each party. Some parties have gained negligible number of votes and will not be in the input — that is the reason that the total number of voters might not be equal to the sum of list votes in the input.

제약

In 30% of the test cases, every party in the input will have at least 5% of the votes.

입력 형식

First line of input contains a positive integer \(X\) (\(1 \le X \le 2\,500\,000\)), total number of voters in the region.

Second line of input contains a positive integer \(N\) (\(0 \le N \le 10\)), number of parties we are considering.

Next \(N\) lines contain two positive integers divided by a single space: party identifier (capital letter of English alphabet) and a positive integer \(G\) (\(0 \le G \le 250\,000\)), number of votes gained by that party.

출력 형식

Output is consisted of number of lines equal to the number of parties which had at least \(5\%\) of the votes. For each of these parties, print a party identifier and a number of parliamentary representatives elected from that party. Lines should be sorted by identifiers, alphabetically.

Scoring: In \(30\%\) of the test cases, every party in the input will have at least \(5\%\) of the votes.

서브태스크
서브태스크점수설명

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
235217
3
A 107382
C 18059
B 43265
출력
A 9
B 4
C 1
예제 2
입력
245143
4
F 14845
A 104516
B 52652
C 14161
출력
A 8
B 4
C 1
F 1
예제 3
입력
206278
5
D 44687
A 68188
C 7008
B 48377
G 9665
출력
A 6
B 4
D 4
문제 정보

riseoj 작성

출처 COCI 2011/2012 Contest 3

평가 및 의견

D'Hondt

개요
출제자 난이도 Silver II 실버 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

D'Hondt

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