Submission #8526089


Source Code Expand

#include <iostream>
using namespace std;
long long n, ans, cnt, mi=1, a[1005], s[2], x[505], y[505], z;
int main() {
	int i, j;
	cin>>n;
	for(i=1; i<=n; i++) {
		cin>>a[i];
		s[i%2] += max(a[i], 0LL);
		if(a[i]>a[mi]) mi=i;
	}
	for(i=s[1]>s[0]; i<=n; i+=2) if(a[i]>0) {
		x[++z] = i;
		if(z>1) cnt += y[z-1] = (x[z] - x[z-1]) / 2;
	}
	if(z) {
		ans = max(s[0], s[1]);
		cnt += x[1]-1 + n-x[z];
	} else {
		ans = a[mi];
		cnt = n-1;
		x[++z] = mi;
	}
	cout<<ans<<endl<<cnt<<endl;
	for(i=n; i>x[z]; i--) cout<<i<<endl;
	for(i=1; i<x[1]; i++) cout<<1<<endl;
	for(i=1; i<z; i++) for(j=y[i]; j; j--) cout<<j+1<<endl;
	return 0;
}

Submission Info

Submission Time
Task E - Both Sides Merger
User luyuchen
Language C++14 (GCC 5.4.1)
Score 700
Code Size 652 Byte
Status AC
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 4
AC × 57
Set Name Test Cases
Sample example_0, example_1, example_2, example_3
All allneg_0, allneg_1, allneg_2, bigans_0, bigans_1, bigans_2, bigans_3, bigans_4, bigans_5, bigans_6, bigans_7, bigans_8, bigans_9, example_0, example_1, example_2, example_3, maxrand_0, maxrand_1, maxrand_10, maxrand_11, maxrand_12, maxrand_13, maxrand_14, maxrand_15, maxrand_16, maxrand_17, maxrand_18, maxrand_19, maxrand_2, maxrand_20, maxrand_21, maxrand_22, maxrand_23, maxrand_24, maxrand_25, maxrand_26, maxrand_27, maxrand_28, maxrand_29, maxrand_3, maxrand_4, maxrand_5, maxrand_6, maxrand_7, maxrand_8, maxrand_9, rand_0, rand_1, rand_2, rand_3, rand_4, rand_5, rand_6, rand_7, rand_8, rand_9
Case Name Status Exec Time Memory
allneg_0 AC 3 ms 256 KB
allneg_1 AC 3 ms 256 KB
allneg_2 AC 3 ms 256 KB
bigans_0 AC 2 ms 256 KB
bigans_1 AC 2 ms 256 KB
bigans_2 AC 2 ms 256 KB
bigans_3 AC 2 ms 256 KB
bigans_4 AC 2 ms 256 KB
bigans_5 AC 2 ms 256 KB
bigans_6 AC 2 ms 256 KB
bigans_7 AC 2 ms 256 KB
bigans_8 AC 2 ms 256 KB
bigans_9 AC 2 ms 256 KB
example_0 AC 1 ms 256 KB
example_1 AC 1 ms 256 KB
example_2 AC 1 ms 256 KB
example_3 AC 1 ms 256 KB
maxrand_0 AC 2 ms 256 KB
maxrand_1 AC 2 ms 256 KB
maxrand_10 AC 2 ms 256 KB
maxrand_11 AC 2 ms 256 KB
maxrand_12 AC 2 ms 256 KB
maxrand_13 AC 2 ms 256 KB
maxrand_14 AC 2 ms 256 KB
maxrand_15 AC 2 ms 256 KB
maxrand_16 AC 2 ms 256 KB
maxrand_17 AC 2 ms 256 KB
maxrand_18 AC 2 ms 256 KB
maxrand_19 AC 2 ms 256 KB
maxrand_2 AC 2 ms 256 KB
maxrand_20 AC 2 ms 256 KB
maxrand_21 AC 2 ms 256 KB
maxrand_22 AC 2 ms 256 KB
maxrand_23 AC 2 ms 256 KB
maxrand_24 AC 2 ms 256 KB
maxrand_25 AC 2 ms 256 KB
maxrand_26 AC 2 ms 256 KB
maxrand_27 AC 2 ms 256 KB
maxrand_28 AC 2 ms 256 KB
maxrand_29 AC 2 ms 256 KB
maxrand_3 AC 2 ms 256 KB
maxrand_4 AC 2 ms 256 KB
maxrand_5 AC 2 ms 256 KB
maxrand_6 AC 2 ms 256 KB
maxrand_7 AC 2 ms 256 KB
maxrand_8 AC 2 ms 256 KB
maxrand_9 AC 2 ms 256 KB
rand_0 AC 2 ms 256 KB
rand_1 AC 2 ms 256 KB
rand_2 AC 1 ms 256 KB
rand_3 AC 2 ms 256 KB
rand_4 AC 2 ms 256 KB
rand_5 AC 2 ms 256 KB
rand_6 AC 2 ms 256 KB
rand_7 AC 2 ms 256 KB
rand_8 AC 2 ms 256 KB
rand_9 AC 2 ms 256 KB