forked from satruddh/Hacktoberfest2k22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
First_and_Last.cpp
49 lines (44 loc) · 863 Bytes
/
First_and_Last.cpp
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
#include<bits/stdc++.h>
#include<vector>
#include <algorithm>
#define ll long long
#define lld long double
#define lli long long int
#define sza(x) ((int)x.size())
#define all(a) (a).begin(),(a).end()
#define vll vector<long long int>
using namespace std;
bool compare(ll a , ll b)
{
if(a>b) return true;
return false;
}
void solve() {
ll n;
cin>>n;
ll*vr = new ll[n];
for (ll i = 0; i < n; i++)
{
cin>>vr[i];
}
ll temp = vr[n-1]+vr[0];
for (ll i = 0; i < n-1; i++)
{
ll ans = vr[i] + vr[i+1];
if (ans > temp)
{
temp = ans;
}
}
cout<<temp<<endl;
delete[] vr;
}
int_fast32_t main () {
ios_base::sync_with_stdio(false);
int t=1;
cin>>t;
for( int k=1;k<=t;k++){
solve();
}
return 0;
}