Submission #1382396
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define forn(i, x, n) for (int i = int(x); i <= int(n); ++i) #define for1(i, n, x) for (int i = int(n); i >= int(x); --i) #define F first #define S second #define pb push_back typedef long long ll; typedef pair <int, int> pii; typedef long double ld; typedef vector <ll> vi; const int N = 2e6 + 1; const int INF = 1e9 + 9; const int B = 1e9 + 7; int n, k, a[N]; ll p[N]; int main() { #ifdef black freopen("in", "r", stdin); #endif // black ios_base :: sync_with_stdio(0); cin.tie(0); cin >> n >> k; forn(i, 1, n) cin >> a[i]; ll ans = 0; forn(i, 1, n - k) { p[i] = p[i - 1]; if (a[i] > 0) p[i] += a[i]; } ans = p[n - k]; ll mx = 0, s = 0; for1(i, n, n - k + 1) { s += a[i]; if (i == n - k + 1) mx = max(mx, s + p[n - k]); else if (i - k >= 1) mx = max(mx, s + p[i - k - 1]); } ans = max(ans, mx); cout << ans << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Contiguous Repainting |
User | sancho |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1094 Byte |
Status | WA |
Exec Time | 13 ms |
Memory | 3072 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 2 ms | 2304 KB |
0_01.txt | AC | 2 ms | 2304 KB |
0_02.txt | AC | 2 ms | 2304 KB |
0_03.txt | AC | 2 ms | 2304 KB |
1_00.txt | AC | 2 ms | 2304 KB |
1_01.txt | AC | 2 ms | 2304 KB |
1_02.txt | AC | 2 ms | 2304 KB |
1_03.txt | AC | 8 ms | 3072 KB |
1_04.txt | AC | 12 ms | 3072 KB |
1_05.txt | AC | 13 ms | 3072 KB |
1_06.txt | AC | 12 ms | 3072 KB |
1_07.txt | AC | 12 ms | 3072 KB |
1_08.txt | AC | 12 ms | 2304 KB |
1_09.txt | AC | 12 ms | 2304 KB |
1_10.txt | WA | 12 ms | 2304 KB |
1_11.txt | WA | 12 ms | 2560 KB |
1_12.txt | WA | 12 ms | 2560 KB |
1_13.txt | WA | 12 ms | 2560 KB |
1_14.txt | WA | 12 ms | 2304 KB |
1_15.txt | WA | 12 ms | 2688 KB |
1_16.txt | WA | 12 ms | 2816 KB |
1_17.txt | WA | 12 ms | 2816 KB |
1_18.txt | WA | 12 ms | 2560 KB |
1_19.txt | WA | 11 ms | 2432 KB |
1_20.txt | WA | 12 ms | 2560 KB |
1_21.txt | WA | 12 ms | 2432 KB |