結果

問題 No.1248 Kth Sum
ユーザー pigeonpigeon
提出日時 2020-10-22 17:05:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 38,200 KB
最終ジャッジ日時 2023-09-28 14:42:28
合計ジャッジ時間 9,894 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
7,776 KB
testcase_01 AC 16 ms
7,780 KB
testcase_02 AC 16 ms
7,864 KB
testcase_03 AC 16 ms
7,936 KB
testcase_04 AC 18 ms
7,792 KB
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 15 ms
7,856 KB
testcase_09 RE -
testcase_10 AC 15 ms
7,796 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 128 ms
36,136 KB
testcase_14 AC 228 ms
37,456 KB
testcase_15 AC 128 ms
36,232 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 213 ms
37,396 KB
testcase_23 AC 17 ms
7,760 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = [ int(a) for a in input().split(' ') ]
alist = [ int(a) for a in input().split(' ') ]

agenda = []
enumed = list(enumerate(alist))
for num_subl in range(1,N//K+1):
    taken = set()
    isum = 0
    prev = -1
    for i in range(num_subl):
        start = max(prev+1, K*(i+1)-1)
        end = start+(num_subl-i-1)*(K-1)+ (N-num_subl*K if i > 0 else 0)
        ind, val = min(enumed[start:end+1], key=lambda p:p[1] if p[0] not in taken else float("inf"))
        taken.add(ind)
        isum += val
        prev = ind
    agenda.append(isum)
print(min(agenda))
0