結果

問題 No.2139 K Consecutive Sushi
ユーザー 👑 rin204rin204
提出日時 2022-12-03 00:07:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 2,071 ms
コンパイル使用メモリ 205,176 KB
実行使用メモリ 12,296 KB
最終ジャッジ日時 2023-07-31 08:45:04
合計ジャッジ時間 5,569 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 137 ms
12,296 KB
testcase_04 AC 143 ms
12,112 KB
testcase_05 AC 138 ms
12,208 KB
testcase_06 AC 133 ms
12,124 KB
testcase_07 AC 139 ms
12,100 KB
testcase_08 AC 138 ms
12,192 KB
testcase_09 AC 140 ms
12,112 KB
testcase_10 AC 144 ms
12,264 KB
testcase_11 AC 141 ms
12,260 KB
testcase_12 AC 135 ms
12,096 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 12 ms
4,380 KB
testcase_24 AC 43 ms
5,588 KB
testcase_25 AC 97 ms
11,204 KB
testcase_26 AC 13 ms
4,380 KB
testcase_27 AC 37 ms
5,540 KB
testcase_28 AC 38 ms
5,464 KB
testcase_29 AC 18 ms
4,384 KB
testcase_30 AC 49 ms
7,148 KB
testcase_31 AC 125 ms
12,008 KB
testcase_32 AC 19 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/lazysegtree>
using namespace std;
using namespace atcoder;
using ll = long long;
const ll inf = 1LL << 60;

using S = ll;
S op(S l, S r){
	return max(l, r);
}
S e(){
	return -inf;
}
using F = ll;
S mapping(F f, S x){
	return f + x;
}
F composition(F l, F r){
	return l + r;
}
F id(){
	return 0;
}

void solve(){    
    int n, k;
	cin >> n >> k;
	vector<ll> A(n);
	for(auto &a : A) cin >> a;
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(n + 1);
	seg.set(0, 0);
	for(int i = 1; i <= n; i++){
		ll a = A[i - 1];
		seg.set(i, seg.prod(0, i));
		seg.apply(max(0, i - k + 1), i, a);
	}
	cout << seg.all_prod() << endl;
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    int t;
    t = 1;
    // cin >> t;
    while(t--) solve();
}
    
    
0