結果
| 問題 | 
                            No.198 キャンディー・ボックス2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             takakin
                         | 
                    
| 提出日時 | 2020-05-22 00:38:51 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 326 bytes | 
| コンパイル時間 | 230 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 10,880 KB | 
| 最終ジャッジ日時 | 2024-10-02 12:03:59 | 
| 合計ジャッジ時間 | 2,129 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 22 WA * 4 | 
ソースコード
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+b>=ctm:
    cur=0
    for e in C:
      cur+=abs(e-c)
    ans=min(ans,cur)
print(ans)
            
            
            
        
            
takakin