Submission #15401600


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1,-1, 0, 0};
int dy[4] = {0, 0, 1,-1};
int dp[200005];
signed main() {
    int N,K;
    cin >> N >> K;
    vector<int>b(N);
    for(int i = 0; i < N; i++) {
        cin >> b[i];
    }
    int mx = 0;
    for(int i = 1; i <= N; i++) {
        if(i < K) {
            dp[i] = dp[i-1]+b[i-1];
        }
        else {
            mx = max(mx,dp[i-K]);
            dp[i] = max({dp[i-1]+b[i-1],mx});
        }
    }
    cout << dp[N] << endl;
}

Submission Info

Submission Time
Task B - Neutralize
User primenumberzz
Language C++ (GCC 9.2.1)
Score 400
Code Size 608 Byte
Status
Exec Time 78 ms
Memory 6408 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03, a04
All 400 / 400 a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44
Case Name Status Exec Time Memory
a01 9 ms 3388 KB
a02 2 ms 3600 KB
a03 1 ms 3460 KB
a04 3 ms 3416 KB
b05 2 ms 3572 KB
b06 2 ms 3416 KB
b07 17 ms 3656 KB
b08 78 ms 6168 KB
b09 78 ms 6172 KB
b10 77 ms 6196 KB
b11 76 ms 6308 KB
b12 3 ms 3456 KB
b13 54 ms 6324 KB
b14 56 ms 6232 KB
b15 73 ms 6332 KB
b16 69 ms 6236 KB
b17 68 ms 6288 KB
b18 76 ms 6284 KB
b19 77 ms 6200 KB
b20 56 ms 5912 KB
b21 56 ms 6232 KB
b22 60 ms 6352 KB
b23 67 ms 6312 KB
b24 44 ms 5496 KB
b25 60 ms 6408 KB
b26 65 ms 6404 KB
b27 48 ms 6236 KB
b28 56 ms 6180 KB
b29 46 ms 6408 KB
b30 39 ms 4648 KB
b31 61 ms 6236 KB
b32 50 ms 5992 KB
b33 44 ms 5644 KB
b34 55 ms 6060 KB
b35 75 ms 6232 KB
b36 75 ms 6168 KB
b37 71 ms 6256 KB
b38 68 ms 6172 KB
b39 71 ms 6408 KB
b40 73 ms 6180 KB
b41 74 ms 6200 KB
b42 69 ms 6352 KB
b43 69 ms 6352 KB
b44 72 ms 6236 KB