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

31366번 - Dividing an orange 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB53448.696%

문제

On a far-away planet i1c5l a community of $n$ people harvested $k$ oranges. Now they have to divide the harvest among themselves.

This community is ruled by a democratic principle based on the rank hierarchy. Thus, the harvest is divided the following way: each person gets a rank from 1ドル$ to $n$. Then, a person ranked 1ドル$ announce his decision: who and how many oranges get. Afterwards all $n$ people vote <<for>> or <<against>>. If at least half of the people vote <<for>>, then the decision is accepted. Otherwise the person ranked 1ドル$ is ostracized from the community and it is turn to person ranked 2ドル$ to announce a decision, and the procedure is repeated.

Each person wish to get the best for himself trying to get as many oranges as possible. Between the cases with equal amount of oranges earned he will prefer the one with less people in community left. If a person is ostracized from the community it is considered that he got a negative amount of oranges. If several optimal solutions exist a person can choose any. Each person knows that other people also try to find the optimal solution being guided by the same principles.

However, one of the community members has $m$ wildcards that can give him predefined ranks. The task is to find out the minimal and the maximum number of oranges that can be obtained for each wildcard rank.

입력

The first line contains integers $n,ドル $k$ and $m$ (1ドル \le n,ドル $k \le 10^9,ドル 1ドル \le m \le 10^5$) --- the amount of people, oranges and wildcards respectively.

The second line contains $m$ integers $a_1,ドル $a_2,ドル ..., $a_m$ (1ドル \le ai \le n$), where $a_i$ --- the rank given by $i$-th wildcard.

출력

For each of $a_i$ write a minimal and a maximum amount of oranges on a separate line, which will be obtained by the wildcard owner or <<-1 -1>> (without quote), if he or she will be ostracized.

제한

예제 입력 1

2 10 2
1 2

예제 출력 1

10 10
0 0

예제 입력 2

3 1 2
1 3

예제 출력 2

0 0
1 1

힌트

In the first example the person with the first rank takes all the oranges and votes <<for>>.

In the second example the person ranked 1 has to give the orange to the person of third rank. If the first one takes one orange then the rest of the members will vote <<against>>. If the first gives the orange to the second then the second will also be <<against>> as he knows that by ostracizing the first they will also get an orange but there will be less people left in the community. Because the third one will also be <<against>> this is not an option for the first one.

출처

Contest > Open Cup > 2014/2015 Season > Stage 11: Grand Prix of Tatarstan > Division 1 K번

Contest > Open Cup > 2014/2015 Season > Stage 11: Grand Prix of Tatarstan > Division 2 K번

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

출처

대학교 대회

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

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