結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 104 ms
83,524 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 63 ms
69,248 KB
testcase_10 AC 62 ms
69,248 KB
testcase_11 AC 65 ms
70,528 KB
testcase_12 AC 75 ms
81,536 KB
testcase_13 WA -
testcase_14 AC 49 ms
59,520 KB
testcase_15 AC 49 ms
59,520 KB
testcase_16 AC 64 ms
70,528 KB
testcase_17 AC 61 ms
69,248 KB
testcase_18 AC 65 ms
70,144 KB
testcase_19 AC 81 ms
75,776 KB
testcase_20 AC 93 ms
81,792 KB
testcase_21 AC 95 ms
81,664 KB
testcase_22 AC 97 ms
81,536 KB
testcase_23 WA -
testcase_24 AC 82 ms
79,232 KB
testcase_25 RE -
testcase_26 AC 101 ms
81,792 KB
testcase_27 AC 103 ms
83,712 KB
testcase_28 RE -
testcase_29 AC 105 ms
83,780 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