結果

問題 No.2139 K Consecutive Sushi
ユーザー baLoon8128baLoon8128
提出日時 2022-12-05 00:53:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 896 bytes
コンパイル時間 4,496 ms
コンパイル使用メモリ 258,072 KB
実行使用メモリ 11,860 KB
最終ジャッジ日時 2024-04-20 05:48:56
合計ジャッジ時間 8,460 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 211 ms
11,776 KB
testcase_04 AC 145 ms
11,788 KB
testcase_05 AC 140 ms
11,776 KB
testcase_06 AC 138 ms
11,680 KB
testcase_07 AC 140 ms
11,748 KB
testcase_08 AC 141 ms
11,776 KB
testcase_09 AC 143 ms
11,860 KB
testcase_10 AC 144 ms
11,648 KB
testcase_11 AC 145 ms
11,688 KB
testcase_12 AC 141 ms
11,776 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 13 ms
5,376 KB
testcase_24 AC 44 ms
5,504 KB
testcase_25 AC 97 ms
10,880 KB
testcase_26 AC 14 ms
5,376 KB
testcase_27 AC 37 ms
5,504 KB
testcase_28 AC 38 ms
5,504 KB
testcase_29 AC 19 ms
5,376 KB
testcase_30 AC 51 ms
7,168 KB
testcase_31 AC 128 ms
11,520 KB
testcase_32 AC 20 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i)

ll op(ll x, ll y) { return max(x, y); }
ll e() { return 0; }
ll mapping(ll f, ll x) { return f + x; }
ll composition(ll f, ll g) { return f + g; }
ll id() { return 0; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    vi a(n);
    rep(i, n) cin >> a[i];
    lazy_segtree<ll, op, e, ll, mapping, composition, id> seg(n + 1);
    rep(i, n) {
        seg.apply(i + 1, seg.prod(max(0, i + 1 - K), i + 1));
        seg.apply(0, i + 1, a[i]);
    }
    ll ret = seg.prod(n - K + 1, n + 1);
    cout << ret << endl;
    return 0;
}
0