結果

問題 No.2139 K Consecutive Sushi
ユーザー roarisroaris
提出日時 2022-12-09 09:26:16
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 5,036 ms
コンパイル使用メモリ 255,388 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-04-22 19:02:10
合計ジャッジ時間 6,614 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 44 ms
10,496 KB
testcase_04 AC 51 ms
10,388 KB
testcase_05 AC 47 ms
10,368 KB
testcase_06 AC 41 ms
10,472 KB
testcase_07 AC 46 ms
10,496 KB
testcase_08 AC 45 ms
10,284 KB
testcase_09 AC 47 ms
10,496 KB
testcase_10 AC 52 ms
10,496 KB
testcase_11 AC 50 ms
10,284 KB
testcase_12 AC 42 ms
10,284 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 1 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 3 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 6 ms
5,376 KB
testcase_24 AC 18 ms
5,376 KB
testcase_25 AC 37 ms
9,432 KB
testcase_26 AC 6 ms
5,376 KB
testcase_27 AC 14 ms
5,376 KB
testcase_28 AC 15 ms
5,376 KB
testcase_29 AC 8 ms
5,376 KB
testcase_30 AC 19 ms
6,400 KB
testcase_31 AC 45 ms
9,984 KB
testcase_32 AC 7 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
typedef long long ll;

ll op(ll x, ll y) { return min(x, y); }
ll e() { return 2000000000000000000ll; }

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    
    int N, K; cin >> N >> K;
    ll A[N]; rep(i, N) cin >> A[i];
    
    segtree<ll, op, e> st(N);
    rep(i, K) st.set(i, A[i]);
    for (int i=K; i<N; i++) st.set(i, st.prod(i-K, i)+A[i]);
    
    ll S = 0ll;
    rep(i, N) S += A[i];
    ll ans = S-st.prod(N-K, N);
    cout << ans << endl;
}
0