-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20190.cpp
More file actions
57 lines (40 loc) · 905 Bytes
/
20190.cpp
File metadata and controls
57 lines (40 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// coded by Cocane
#include<bits/stdc++.h>
#define ll long long
#define forn(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define out(ans) cout<<ans<<endl
using namespace std;
typedef vector<int> vi;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--) {
int n;
cin >> n;
vi v(n);
for(auto &it : v) cin >> it;
int mx_odd = 0;
int ct_odd = 0;
for (int i = 0; i < n; i+=2)
{
mx_odd = max(mx_odd, v[i]);
ct_odd++;
}
int mx_even = 0;
int ct_even = 0;
for (int i = 1; i < n; i+=2)
{
mx_even = max(mx_even, v[i]);
ct_even++;
}
int score_odd = mx_odd + ct_odd;
int score_even = mx_even + ct_even;
cout<<max(score_odd , score_even)<<endl;
}
return 0;
}