Language: C++

// finish date: 2018/03/17

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vl a(N);
    int maxVal = -INT_MAX;
    int maxIndex;
    rep(i, N) {
        cin >> a[i];
        if (maxVal < a[i]) {
            maxVal = a[i];
            maxIndex = i;
        }
    }
    if (N == 2) {
        cout << max(a[0], a[1]) << endl;
        cout << 1 << endl;
        if (a[0] > a[1]) cout << 2 << endl;
        else cout << 1 << endl;
        return 0;
    }
    if (maxVal <= 0) {
        cout << maxVal << endl;
        cout << N - 1 << endl;
        FOR(i, maxIndex + 1, N) {
            cout << maxIndex + 2 << endl;
        }
        rep(i, maxIndex) {
            cout << 1 << endl;
        }
        return 0;
    }


    ll oddMax = 0;
    ll evenMax = 0;
    rep(i, N) {
        if (i % 2 == 0) oddMax += max(a[i], 0);
        else evenMax += max(a[i], 0);
    }
    vi operate;
    int l, r;
    if (oddMax > evenMax) l = 0;
    else {
        operate.emplace_back(0);
        l = 1;
    }
    r = l + 1;
    while (r < N) {
        if (r+1 >= N) {
            operate.emplace_back(1);
            break;
        }
        if (a[l] < 0) {
            operate.emplace_back(0);
            operate.emplace_back(0);
            l += 2;
            r = l + 1;
        } else if (a[r + 1] < 0) {
            operate.emplace_back(2);
            r += 2;

        } else {
            operate.emplace_back(1);
            a[r] += a[l];
            l += r;
            r = l + 1;
        }

    }

    cout << max(evenMax, oddMax) << endl;
    cout << operate.size() << endl;
    rep(i, operate.size()) {
        cout << operate[i] + 1 << endl;
    }


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:38: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int)'
   63 |         if (i % 2 == 0) oddMax += max(a[i], 0);
      |                                   ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:63:38: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   63 |         if (i % 2 == 0) oddMax += max(a[i], 0);
      |                                   ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:63:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   63 |         if (i % 2 == 0) oddMax += max(a[i], 0);
      |                                   ~~~^~~~~~~~~
a.cc:64:28: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int)'
   64 |         else evenMax += max(a[i], 0);
      |                         ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:64:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   64 |         else evenMax += max(a[i], 0);
      |                         ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:64:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   64 |         else evenMax += max(a[i], 0);
      |                         ~~~^~~~~~~~~