結果

問題 No.198 キャンディー・ボックス2
ユーザー あかりきあかりき
提出日時 2021-03-14 20:57:34
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 386 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 84,336 KB
最終ジャッジ日時 2024-11-06 09:42:39
合計ジャッジ時間 3,940 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 96 ms
83,608 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 56 ms
69,632 KB
testcase_10 AC 56 ms
69,760 KB
testcase_11 AC 60 ms
70,400 KB
testcase_12 AC 68 ms
81,536 KB
testcase_13 WA -
testcase_14 AC 46 ms
59,520 KB
testcase_15 AC 47 ms
59,520 KB
testcase_16 AC 56 ms
70,784 KB
testcase_17 AC 54 ms
69,760 KB
testcase_18 AC 56 ms
70,272 KB
testcase_19 AC 71 ms
76,160 KB
testcase_20 AC 83 ms
81,696 KB
testcase_21 AC 91 ms
81,920 KB
testcase_22 AC 87 ms
81,928 KB
testcase_23 WA -
testcase_24 AC 77 ms
79,488 KB
testcase_25 RE -
testcase_26 AC 95 ms
81,920 KB
testcase_27 AC 95 ms
83,584 KB
testcase_28 RE -
testcase_29 AC 95 ms
83,612 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
x=sum(c)+b
ans=[]
for i in range(max(t-10**5,0),t+10**5):
  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