結果
| 問題 | No.3683 サーバー代がもったいない! |
| コンテスト | |
| ユーザー |
redallen@競プロ
|
| 提出日時 | 2026-09-05 14:37:51 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 577 bytes |
| 記録 | |
| コンパイル時間 | 251 ms |
| コンパイル使用メモリ | 95,704 KB |
| 実行使用メモリ | 109,184 KB |
| 最終ジャッジ日時 | 2026-09-05 14:37:58 |
| 合計ジャッジ時間 | 5,679 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 9 |
ソースコード
from heapq import heapify, heappop, heappush
N,K=map(int,input().split())
A=list(map(int,input().split()))
if N%2==1 and N//2+1<K:
print("Impossible")
elif N%2==0 and N//2<K:
print("Impossible")
else:
EA=list(map(list,sorted(enumerate(A),key=lambda x: x[1],reverse=True)))
ANS=0
ANS+=EA[0][1]
T=EA[0][0]
CNT=1
for i in range(1,N):
if abs(T-EA[i][0])>1:
CNT+=1
T=EA[i][0]
ANS+=EA[i][1]
if CNT==K:
break
if CNT==K:
print(ANS)
else:
print("Impossible")
redallen@競プロ