Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #4540661

Source Code Expand

Copy
```#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

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;
bool f = (idx == 1);
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;
if(I[idx].back() == 1) f = !f;
N -= 2;
I[idx].pop_back();
}
if(f){
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 2019-03-10 18:06:46+0900 E - Both Sides Merger TAB C++14 (GCC 5.4.1) 700 1142 Byte AC 4 ms 256 KB

#### Judge Result

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