結果
問題 | No.1248 Kth Sum |
ユーザー | chineristAC |
提出日時 | 2020-10-02 22:12:31 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 550 bytes |
コンパイル時間 | 271 ms |
コンパイル使用メモリ | 87,100 KB |
実行使用メモリ | 106,268 KB |
最終ジャッジ日時 | 2023-09-24 20:56:54 |
合計ジャッジ時間 | 7,877 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
71,320 KB |
testcase_01 | AC | 76 ms
71,092 KB |
testcase_02 | AC | 74 ms
71,140 KB |
testcase_03 | AC | 76 ms
71,244 KB |
testcase_04 | AC | 75 ms
71,048 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 72 ms
71,304 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 125 ms
101,728 KB |
testcase_14 | WA | - |
testcase_15 | AC | 123 ms
101,740 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 75 ms
71,236 KB |
testcase_24 | WA | - |
testcase_25 | AC | 252 ms
105,960 KB |
testcase_26 | WA | - |
testcase_27 | AC | 123 ms
101,908 KB |
testcase_28 | AC | 123 ms
101,828 KB |
testcase_29 | AC | 126 ms
101,736 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
ソースコード
from heapq import heappush,heappop,heapify N,K = map(int,input().split()) A = list(map(int,input().split())) if K==1: exit(print(A[0])) ans = 10**18 que = [] S = 0 for i in range(1,N+1): if i*K>N: break tmp = A[i*K-1] if i!=1: t = A[(i-1)*K:i*K-1] t.sort(reverse=True) while t and -que[0] > t[-1]: S += que[0] heappop(que) S += t[-1] heappush(que,-t.pop()) tmp += S ans = min(ans,tmp) S += A[i*K-1] heappush(que,-A[i*K-1]) print(ans)