Submission #23985904


Source Code Expand

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

people = {}
for i in range(N):
  people[i] = A[i]

sorted_people = sorted(people.items(), key=lambda x:x[1])

ok = {}
for i in range(N):
  ok[i] = sorted_people[i]

ok = sorted(ok.items(), key=lambda x:x[1][0])

if K >= N:
  min_candy = K // N
  thresh = K - min_candy * N

  if thresh >= N:
    min_candy += 1
    thresh = K - min_candy * N

  for p in ok:
    if p[0] + 1 <= thresh:
      print(min_candy + 1)
    else:
      print(min_candy)
else:
  min_candy = 0
  thresh = K

  for p in ok:
    if p[0] + 1 <= thresh:
      print(min_candy + 1)
    else:
      print(min_candy)


Submission Info

Submission Time
Task C - Fair Candy Distribution
User Tommy3
Language Python (3.8.2)
Score 300
Code Size 700 Byte
Status AC
Exec Time 578 ms
Memory 87500 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 25
Set Name Test Cases
Sample sample_00.txt, sample_01.txt, sample_02.txt
All exact_div_00.txt, k_lt_n_00.txt, max_00.txt, max_01.txt, max_ascend_00.txt, max_ascend_01.txt, max_descend_00.txt, max_descend_01.txt, max_random_00.txt, max_random_01.txt, n_k_small_00.txt, n_k_small_01.txt, n_k_small_02.txt, n_k_small_03.txt, n_k_small_04.txt, n_small_00.txt, n_small_01.txt, n_small_02.txt, n_small_03.txt, n_small_04.txt, random_00.txt, random_01.txt, sample_00.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
exact_div_00.txt AC 81 ms 19636 KiB
k_lt_n_00.txt AC 134 ms 28692 KiB
max_00.txt AC 557 ms 87372 KiB
max_01.txt AC 555 ms 87500 KiB
max_ascend_00.txt AC 319 ms 87372 KiB
max_ascend_01.txt AC 321 ms 87452 KiB
max_descend_00.txt AC 321 ms 87460 KiB
max_descend_01.txt AC 317 ms 87416 KiB
max_random_00.txt AC 578 ms 87368 KiB
max_random_01.txt AC 544 ms 87460 KiB
n_k_small_00.txt AC 18 ms 8912 KiB
n_k_small_01.txt AC 18 ms 8912 KiB
n_k_small_02.txt AC 25 ms 8920 KiB
n_k_small_03.txt AC 23 ms 8920 KiB
n_k_small_04.txt AC 20 ms 8916 KiB
n_small_00.txt AC 20 ms 9076 KiB
n_small_01.txt AC 23 ms 8908 KiB
n_small_02.txt AC 19 ms 9080 KiB
n_small_03.txt AC 19 ms 9096 KiB
n_small_04.txt AC 26 ms 8920 KiB
random_00.txt AC 286 ms 50008 KiB
random_01.txt AC 304 ms 52432 KiB
sample_00.txt AC 25 ms 9088 KiB
sample_01.txt AC 19 ms 9140 KiB
sample_02.txt AC 18 ms 9088 KiB