Submission #4512772


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  vector< vector<long long> > S(2,vector<long long>(N+1,0));
  for(int i = 0; i < N; ++i){
    cin >> A[i];
    S[1-i%2][i+1] = A[i];
  }
  for(int i = 0; i < N; ++i) S[0][i+1] += S[0][i], S[1][i+1] += S[1][i];
  long long ans = 0, l = 0, r = 1;
  for(int i = 0; i < N; ++i){
    for(int j = i+1; j <= N; ++j){
      if((j-i)%2 == 0) continue;
      long long t = S[j%2][j] - S[j%2][i];
      if(t < ans) continue;
      l = i;
      r = j;
      ans = t;
    }
  }
  cout << ans << endl;
  vector<int> V;
  for(int i = N; i > r; --i) V.push_back(i);
  for(int i = 0; i < l; ++i) V.push_back(1);
  while(r-l > 2){
    --r;
    V.push_back(2);
  }
  cout << V.size() << endl;
  for(auto e : V) 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 902 Byte
Status
Exec Time 4 ms
Memory 256 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 4 ms 256 KB
allneg_1 4 ms 256 KB
allneg_2 4 ms 256 KB
bigans_0 4 ms 256 KB
bigans_1 4 ms 256 KB
bigans_2 4 ms 256 KB
bigans_3 4 ms 256 KB
bigans_4 4 ms 256 KB
bigans_5 4 ms 256 KB
bigans_6 4 ms 256 KB
bigans_7 4 ms 256 KB
bigans_8 4 ms 256 KB
bigans_9 4 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 4 ms 256 KB
maxrand_1 4 ms 256 KB
maxrand_10 4 ms 256 KB
maxrand_11 4 ms 256 KB
maxrand_12 4 ms 256 KB
maxrand_13 4 ms 256 KB
maxrand_14 4 ms 256 KB
maxrand_15 4 ms 256 KB
maxrand_16 4 ms 256 KB
maxrand_17 4 ms 256 KB
maxrand_18 4 ms 256 KB
maxrand_19 4 ms 256 KB
maxrand_2 4 ms 256 KB
maxrand_20 4 ms 256 KB
maxrand_21 4 ms 256 KB
maxrand_22 4 ms 256 KB
maxrand_23 4 ms 256 KB
maxrand_24 4 ms 256 KB
maxrand_25 4 ms 256 KB
maxrand_26 4 ms 256 KB
maxrand_27 4 ms 256 KB
maxrand_28 4 ms 256 KB
maxrand_29 4 ms 256 KB
maxrand_3 4 ms 256 KB
maxrand_4 4 ms 256 KB
maxrand_5 4 ms 256 KB
maxrand_6 4 ms 256 KB
maxrand_7 4 ms 256 KB
maxrand_8 4 ms 256 KB
maxrand_9 4 ms 256 KB
rand_0 3 ms 256 KB
rand_1 2 ms 256 KB
rand_2 2 ms 256 KB
rand_3 2 ms 256 KB
rand_4 4 ms 256 KB
rand_5 2 ms 256 KB
rand_6 3 ms 256 KB
rand_7 2 ms 256 KB
rand_8 3 ms 256 KB
rand_9 3 ms 256 KB