Submission #8526028


Source Code Expand

#include<cstdio>
#include<algorithm>
#define int long long
int n,a[1010],sum0,sum1;
int b[1010],tot;
signed main(){
	scanf("%lld",&n);
	int len=n;
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++){
		if(a[i]<0)continue;
		if(i%2==0)sum0+=a[i];
		else sum1+=a[i]; 
	}
	bool flag=sum0>sum1;
	printf("%lld\n",std::max(sum0,sum1));
	while(1==flag||a[1]<0){
		b[++tot]=1;
		for(int i=1;i<len;i++)
			a[i]=a[i+1];
		flag=1-flag;
		len--;
	}
	while(len%2==flag||a[len]<0){
		b[++tot]=len;
		len--;
	}
	while(len>1){
		bool bo=false;
		for(int i=1;i<=len;i++)
			if(i%2!=flag&&a[i]<0){
				b[++tot]=len;
				bo=true;
				a[i-1]+=a[i+1];
				for(int j=i;j<=len-2;j++)
					a[j]=a[j+2];
				len-=2;
				break;
			}
		if(!bo)break;
	}
	while(len>1){
		b[++tot]=2;
		len-=2;
	}
	printf("%lld\n",tot);
	for(int i=1;i<=tot;i++)
		printf("%lld\n",b[i]);
}

Submission Info

Submission Time
Task E - Both Sides Merger
User luyuchen
Language C++14 (GCC 5.4.1)
Score 0
Code Size 904 Byte
Status WA
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:7:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
                  ^
./Main.cpp:9:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
                                          ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 4
AC × 4
WA × 53
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 WA 1 ms 128 KB
allneg_1 WA 1 ms 128 KB
allneg_2 WA 1 ms 128 KB
bigans_0 WA 1 ms 128 KB
bigans_1 WA 1 ms 128 KB
bigans_2 WA 1 ms 128 KB
bigans_3 WA 1 ms 128 KB
bigans_4 WA 1 ms 128 KB
bigans_5 WA 1 ms 128 KB
bigans_6 WA 1 ms 128 KB
bigans_7 WA 1 ms 128 KB
bigans_8 WA 1 ms 128 KB
bigans_9 WA 1 ms 128 KB
example_0 AC 1 ms 128 KB
example_1 AC 1 ms 128 KB
example_2 AC 1 ms 128 KB
example_3 AC 1 ms 128 KB
maxrand_0 WA 1 ms 128 KB
maxrand_1 WA 1 ms 128 KB
maxrand_10 WA 1 ms 128 KB
maxrand_11 WA 1 ms 128 KB
maxrand_12 WA 1 ms 128 KB
maxrand_13 WA 1 ms 128 KB
maxrand_14 WA 1 ms 128 KB
maxrand_15 WA 1 ms 128 KB
maxrand_16 WA 1 ms 128 KB
maxrand_17 WA 1 ms 128 KB
maxrand_18 WA 1 ms 128 KB
maxrand_19 WA 1 ms 128 KB
maxrand_2 WA 1 ms 128 KB
maxrand_20 WA 1 ms 128 KB
maxrand_21 WA 1 ms 128 KB
maxrand_22 WA 1 ms 128 KB
maxrand_23 WA 1 ms 128 KB
maxrand_24 WA 1 ms 128 KB
maxrand_25 WA 1 ms 128 KB
maxrand_26 WA 1 ms 128 KB
maxrand_27 WA 1 ms 128 KB
maxrand_28 WA 1 ms 128 KB
maxrand_29 WA 1 ms 128 KB
maxrand_3 WA 1 ms 128 KB
maxrand_4 WA 1 ms 128 KB
maxrand_5 WA 1 ms 128 KB
maxrand_6 WA 1 ms 128 KB
maxrand_7 WA 1 ms 128 KB
maxrand_8 WA 1 ms 128 KB
maxrand_9 WA 1 ms 128 KB
rand_0 WA 1 ms 128 KB
rand_1 WA 1 ms 128 KB
rand_2 WA 1 ms 128 KB
rand_3 WA 1 ms 128 KB
rand_4 WA 1 ms 128 KB
rand_5 WA 1 ms 128 KB
rand_6 WA 1 ms 128 KB
rand_7 WA 1 ms 128 KB
rand_8 WA 1 ms 128 KB
rand_9 WA 1 ms 128 KB