Submission #15401606


Source Code Expand

Copy
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int &i:A)cin>>i;
  vector<vector<int>> B(N+1,vector<int>(2,-1000000000000000000));
  B[0][0]=B[0][1]=0;
  for(int i=1;i<=N;i++){
    B[i][1]=max(B[i-1][1],B[i-1][0])+A[i-1];
    if(i>=K)B[i][0]=max(B[i-1][0],B[i-K][1]);
  }
  cout<<max(B[N][0],B[N][1])<<endl;
}

Submission Info

Submission Time
Task B - Neutralize
User shiomusubi496
Language C++ (GCC 9.2.1)
Score 400
Code Size 408 Byte
Status
Exec Time 92 ms
Memory 15668 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 6 ms 3600 KB
a02 2 ms 3508 KB
a03 2 ms 3480 KB
a04 2 ms 3420 KB
b05 2 ms 3472 KB
b06 3 ms 3408 KB
b07 16 ms 4468 KB
b08 90 ms 15484 KB
b09 92 ms 15524 KB
b10 91 ms 15576 KB
b11 89 ms 15584 KB
b12 2 ms 3476 KB
b13 72 ms 15488 KB
b14 73 ms 15596 KB
b15 80 ms 15576 KB
b16 79 ms 15492 KB
b17 82 ms 15524 KB
b18 82 ms 15612 KB
b19 85 ms 15492 KB
b20 68 ms 14556 KB
b21 61 ms 15488 KB
b22 75 ms 15424 KB
b23 83 ms 15492 KB
b24 57 ms 12944 KB
b25 72 ms 15492 KB
b26 73 ms 15576 KB
b27 62 ms 15556 KB
b28 67 ms 15600 KB
b29 60 ms 15572 KB
b30 53 ms 9888 KB
b31 71 ms 15616 KB
b32 61 ms 14936 KB
b33 53 ms 13144 KB
b34 67 ms 14432 KB
b35 82 ms 15428 KB
b36 88 ms 15668 KB
b37 87 ms 15424 KB
b38 88 ms 15488 KB
b39 81 ms 15428 KB
b40 81 ms 15520 KB
b41 85 ms 15596 KB
b42 87 ms 15484 KB
b43 85 ms 15488 KB
b44 85 ms 15664 KB