結果

問題 No.2139 K Consecutive Sushi
ユーザー V_MelvilleV_Melville
提出日時 2022-12-19 22:16:06
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 5,710 ms
コンパイル使用メモリ 309,848 KB
実行使用メモリ 9,760 KB
最終ジャッジ日時 2024-04-29 02:33:24
合計ジャッジ時間 7,043 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 89 ms
9,628 KB
testcase_04 AC 93 ms
9,640 KB
testcase_05 AC 87 ms
9,624 KB
testcase_06 AC 81 ms
9,760 KB
testcase_07 AC 86 ms
9,760 KB
testcase_08 AC 85 ms
9,604 KB
testcase_09 AC 90 ms
9,680 KB
testcase_10 AC 89 ms
9,628 KB
testcase_11 AC 90 ms
9,644 KB
testcase_12 AC 84 ms
9,636 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 10 ms
6,944 KB
testcase_24 AC 29 ms
6,944 KB
testcase_25 AC 61 ms
8,872 KB
testcase_26 AC 10 ms
6,944 KB
testcase_27 AC 25 ms
6,940 KB
testcase_28 AC 25 ms
6,940 KB
testcase_29 AC 13 ms
6,940 KB
testcase_30 AC 32 ms
6,944 KB
testcase_31 AC 75 ms
9,484 KB
testcase_32 AC 14 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

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

ll e() { return 1e18; }

int main() {
    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    ll ans = 0;
    rep(i, n) ans += a[i];
    
    segtree<ll, op, e> t(n);
    rep(i, k) t.set(i, a[i]);
    for (int i = k; i < n; ++i) {
        ll now = t.prod(i-k, i)+a[i];
        t.set(i, now);
    }
    ans -= t.prod(n-k, n);
    
    cout << ans << '\n';
    
    return 0;
}
0