結果

問題 No.324 落ちてた閉路グラフ
ユーザー mkawa2mkawa2
提出日時 2020-02-27 08:58:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-21 16:46:54
合計ジャッジ時間 2,547 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 AC 42 ms
11,136 KB
testcase_05 AC 35 ms
11,264 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 43 ms
11,136 KB
testcase_09 AC 45 ms
11,264 KB
testcase_10 AC 43 ms
11,264 KB
testcase_11 AC 46 ms
11,136 KB
testcase_12 AC 46 ms
11,264 KB
testcase_13 AC 39 ms
11,008 KB
testcase_14 AC 32 ms
10,880 KB
testcase_15 AC 32 ms
10,880 KB
testcase_16 AC 31 ms
10,880 KB
testcase_17 AC 31 ms
10,752 KB
testcase_18 AC 31 ms
10,752 KB
testcase_19 AC 31 ms
10,752 KB
testcase_20 AC 31 ms
10,880 KB
testcase_21 AC 31 ms
10,752 KB
testcase_22 AC 31 ms
10,880 KB
testcase_23 AC 34 ms
10,752 KB
testcase_24 AC 31 ms
10,880 KB
testcase_25 WA -
testcase_26 AC 32 ms
10,752 KB
testcase_27 WA -
testcase_28 AC 31 ms
10,880 KB
testcase_29 AC 31 ms
10,752 KB
testcase_30 AC 31 ms
10,752 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)%n] + ww[i], i))
    diff=n-m
    used=[False]*n
    while diff:
        s,i=heappop(hp)
        if used[i] or s!=ww[(i-1)%n]+ww[i]:continue
        used[i]=True
        ww[(i-1)%n]=ww[i]=0
        heappush(hp,(ww[(i-2)%n]+ww[(i-1)%n],(i-1)%n))
        heappush(hp,(ww[i]+ww[(i+1)%n],(i+1)%n))
        diff-=1
    print(sum(ww))

main()
0