結果

問題 No.198 キャンディー・ボックス2
ユーザー あかりきあかりき
提出日時 2021-03-15 00:00:04
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 375 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 170,112 KB
最終ジャッジ日時 2024-04-24 05:10:16
合計ジャッジ時間 9,652 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 416 ms
159,596 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 390 ms
159,968 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 104 ms
75,488 KB
testcase_10 AC 102 ms
75,468 KB
testcase_11 AC 114 ms
75,520 KB
testcase_12 AC 179 ms
170,112 KB
testcase_13 WA -
testcase_14 AC 51 ms
59,684 KB
testcase_15 AC 51 ms
59,776 KB
testcase_16 AC 97 ms
75,588 KB
testcase_17 AC 109 ms
75,304 KB
testcase_18 AC 117 ms
75,648 KB
testcase_19 AC 159 ms
75,904 KB
testcase_20 AC 292 ms
107,076 KB
testcase_21 AC 318 ms
107,200 KB
testcase_22 AC 317 ms
107,396 KB
testcase_23 WA -
testcase_24 AC 214 ms
110,040 KB
testcase_25 RE -
testcase_26 AC 358 ms
109,532 KB
testcase_27 AC 391 ms
159,584 KB
testcase_28 RE -
testcase_29 AC 398 ms
159,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

b=int(input())
n=int(input())
c=[int(input()) for i in range(n)]
c.sort()
if n//2==1:
  t=c[n//2]
else:
  t=(c[n//2-1]+c[n//2])//2
ans=[]
for i in range(max(t-10**6,0),t+10**6):
  ct=0
  y=b
  for j in range(n):
    if c[j]>=i:
      ct+=c[j]-i
      y+=c[j]-i
  for j in range(n):
    if c[j]<i:
      ct+=i-c[j]
      y-=i-c[j]
  if y>=0:
    ans.append(ct)
print(min(ans))
0