Contest Duration: ~ (local time) (110 minutes) Back to Home

Submission #1041655

Source Code Expand

Copy
```#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int,int> mii;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = b-1; i >= a; i--)
#define F0Rd(i,a) for (int i = a-1; i >= 0; i--)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

map<int,vi> a2;
ll e,o;

int main() {
ios_base::sync_with_stdio(0);cin.tie(0);
int N,K; cin >> N >> K;
F0R(i,N) {
int x; cin >> x;
a2[i % K].pb(x);
}
F0R(i,K) {
vi z = a2[i];
sort(z.begin(),z.end());
reverse(z.begin(),z.end());
ll csum = 0, cind = 0;
for(;cind<z.size();++cind){
if (z[cind]<0) {
cind --;
break;
}
csum += z[cind];
}
if (cind == -1) {
o += z[0];
} else if (cind % 2 == 0) {
o += csum;
e += csum-z[cind];
} else {
e += csum;
o += csum-z[cind];
}
}
cout << max(e,o);
}```

#### Submission Info

Submission Time 2016-12-25 21:18:05+0900 B - Contiguous Repainting Benq C++14 (GCC 5.4.1) 0 1136 Byte WA 68 ms 11136 KB

#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 0 / 400 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 3 ms 384 KB
0_01.txt 3 ms 256 KB
0_02.txt 3 ms 256 KB
0_03.txt 3 ms 256 KB
1_00.txt 3 ms 256 KB
1_01.txt 3 ms 256 KB
1_02.txt 3 ms 256 KB
1_03.txt 12 ms 1144 KB
1_04.txt 16 ms 1144 KB
1_05.txt 17 ms 1144 KB
1_06.txt 21 ms 1144 KB
1_07.txt 21 ms 1144 KB
1_08.txt 67 ms 11008 KB
1_09.txt 68 ms 11136 KB
1_10.txt 65 ms 11008 KB
1_11.txt 50 ms 7680 KB
1_12.txt 46 ms 6784 KB
1_13.txt 51 ms 7680 KB
1_14.txt 64 ms 10752 KB
1_15.txt 43 ms 6016 KB
1_16.txt 37 ms 4352 KB
1_17.txt 33 ms 3456 KB
1_18.txt 51 ms 7680 KB
1_19.txt 60 ms 9344 KB
1_20.txt 52 ms 8192 KB
1_21.txt 60 ms 9856 KB