結果
| 問題 |
No.324 落ちてた閉路グラフ
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2020-02-27 08:49:30 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 810 bytes |
| コンパイル時間 | 95 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2024-10-13 15:44:49 |
| 合計ジャッジ時間 | 2,398 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 WA * 11 RE * 1 |
ソースコード
from heapq import *
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
def main():
n, m = MI()
ww = LI()
hp = []
for i in range(n): heappush(hp, (ww[i - 1] + ww[i], i))
diff=n-m
used=[False]*n
while diff:
s,i=heappop(hp)
if used[i] or s!=ww[i-1]+ww[i]:continue
used[i]=True
ww[i-1]=ww[i]=0
heappush(hp,(ww[i-2]+ww[i-1],i-1))
heappush(hp,(ww[i]+ww[(i+1)%n],(i+1)%n))
diff-=1
print(sum(ww))
main()
mkawa2