結果

問題 No.198 キャンディー・ボックス2
ユーザー takakin
提出日時 2020-05-22 00:35:21
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 322 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-02 12:00:41
合計ジャッジ時間 2,129 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 WA * 7 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
b=int(input())
n=int(input())
C=[int(input()) for _ in range(n)]
ans=float("inf")
for c in C:
  ctp=0
  ctm=0
  for d in C:
    if d>c:
      ctp+=d-c
    else:
      ctm+=c-d
  if ctp>=ctm:
    cur=0
    for e in C:
      cur+=abs(e-c)
  ans=min(ans,cur)
print(ans)
0