結果

問題 No.2139 K Consecutive Sushi
ユーザー trineutrontrineutron
提出日時 2022-12-03 18:51:16
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 3,717 ms
コンパイル使用メモリ 279,880 KB
実行使用メモリ 10,696 KB
最終ジャッジ日時 2024-04-19 05:08:06
合計ジャッジ時間 6,425 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 110 ms
10,416 KB
testcase_04 AC 109 ms
10,696 KB
testcase_05 AC 110 ms
10,460 KB
testcase_06 AC 110 ms
10,616 KB
testcase_07 AC 109 ms
10,452 KB
testcase_08 AC 101 ms
10,496 KB
testcase_09 AC 103 ms
10,464 KB
testcase_10 AC 103 ms
10,484 KB
testcase_11 AC 107 ms
10,624 KB
testcase_12 AC 100 ms
10,572 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 11 ms
5,376 KB
testcase_24 AC 36 ms
5,376 KB
testcase_25 AC 73 ms
9,472 KB
testcase_26 AC 13 ms
5,376 KB
testcase_27 AC 30 ms
5,376 KB
testcase_28 AC 32 ms
5,376 KB
testcase_29 AC 15 ms
5,376 KB
testcase_30 AC 41 ms
6,528 KB
testcase_31 AC 98 ms
10,240 KB
testcase_32 AC 18 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/segtree>

using namespace std;
using namespace atcoder;

using S = int64_t;

S op(S a, S b) { return min(a, b); }

S e() { return 1e18; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int64_t> a(n);
    for (auto &&x : a) {
        cin >> x;
    }

    segtree<S, op, e> seg(n + 1);
    seg.set(0, 0);
    for (int i = 0; i < n; i++) {
        int l = i < k ? 0 : i - k + 1;
        seg.set(i + 1, seg.prod(l, i + 1) + a.at(i));
    }

    cout << reduce(a.begin(), a.end()) - seg.prod(n - k + 1, n + 1) << endl;

    return 0;
}
0