結果
問題 |
No.370 道路の掃除
|
ユーザー |
![]() |
提出日時 | 2022-12-20 04:49:18 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 388 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-18 01:44:11 |
合計ジャッジ時間 | 2,494 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
N,m=map(int,input().split()) M=[] P=[] Z=0 for i in range(m): x=int(input()) if x==0: Z+=1 elif x<0: M.append(-x) else: P.append(x) M.append(0) P.append(0) M.sort() P.sort() N-=Z if N<=0: print(0) exit() ANS=1<<63 for i in range(len(M)): j=N-i if j<len(P): ANS=min(ANS,M[i]*2+P[j],M[i]+P[j]*2) print(ANS)