Submission #4513885


Source Code Expand

Copy
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
const long long INF = 1e18;

int main(){
  long long N;
  cin >> N;
  vector<long long> A(N);
  long long s[] = {0,0};
  vector< vector<int> > I(2);
  for(int i = 0; i < N; ++i){
    cin >> A[i];
    if(A[i] < 0)
      I[i%2].push_back(i+1);
    else
      s[i%2] += A[i];
  }
  if(*max_element(A.begin(), A.end()) < 0){
    int idx = max_element(A.begin(), A.end()) - A.begin();
    cout << A[idx] << endl << N-1 << endl;;
    ++idx;
    for(int i = N; i > idx; --i) cout << i << endl;
    for(int i = 1; i < idx; ++i) cout << 1 << endl;
    return 0;
  }
  int idx;
  if(s[0] < s[1]) idx = 1;
  else idx = 0;
  cout << s[idx] << endl;
  vector<int> C;
  while(not I[idx].empty()){
    C.push_back(I[idx].back());
    if(I[idx].back() == N or I[idx].back() == 1) ++N;
    N -= 2;
    I[idx].pop_back();
  }
  if(idx == 1){
    C.push_back(1);
    --N;
  }
  while(N > 1){
    C.push_back(2);
    N -= 2;
  }
  cout << C.size() << endl;
  for(auto e : C) cout << e << endl;
  return 0;
}

Submission Info

Submission Time
Task E - Both Sides Merger
User TAB
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1138 Byte
Status
Exec Time 11 ms
Memory 764 KB

Test Cases

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