Submission #2859164


Source Code Expand

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  LL ki=0,gu=0;
  vector<LL> a(n);
  vector<bool> kiused(n,false),guused(n,false);
  int kicount=0,gucount=0;
  bool neg=true;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i%2){
      if(a[i]>=0){
        ki+=a[i];
        kiused[i]=true;
        neg=false;
        kicount++;
      }
    }else{
      if(a[i]>0){
        gu+=a[i];
        guused[i]=true;
        neg=false;
        gucount++;
      }
    }
  }
  if(neg){
    LL mi=-1000000000;
    int pos;
    for(int i=0;i<n;i++){
      if(a[i]>mi){
        mi=a[i];
        pos=i;
      }
    }
    cout << mi << endl;
    for(int i=0;i<pos;i++){
      cout << i+1 << endl;
    }
    for(int i=pos+1;i<n;i++){
      cout << i+1 << endl;
    }
  }else{
    if(ki>gu){
      cout << ki << endl;
      cout << n-kicount << endl;
      int i;
      for(i=n-1;!kiused[i];i--) cout << i+1 << endl;
      int pre=i;
      for(;i>=0;i--){
        if(kiused[i]){
          for(int j=(i+pre)/2;j>i;j--) cout << j+1 << endl;
          pre=i;
        }
      }
      for(int j=0;j<pre;j++) cout << j+1 << endl;
    }else{
      cout << gu << endl;
      cout << n-gucount << endl;
      int i;
      for(i=n-1;!guused[i];i--) cout << i+1 << endl;
      int pre=i;
      for(;i>=0;i--){
        if(guused[i]){
          for(int j=(i+pre)/2;j>i;j--) cout << j+1 << endl;
          pre=i;
        }
      }
      for(int j=0;j<pre;j++) cout << j+1 << endl;
    }
  }
  return 0;
}

Submission Info

Submission Time
Task E - Both Sides Merger
User yamunaku
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1679 Byte
Status WA
Exec Time 3 ms
Memory 256 KB

Judge Result

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