-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f73891
commit a6d6548
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
typedef long long LL ; | ||
typedef pair<int,int> pii; | ||
const int N = 2e5+50 , mod = 1e9+7; | ||
|
||
LL n , m , q , k ,ans ; | ||
LL a[N] ; | ||
void AC() { | ||
cin >> n ; ans = 0 ; | ||
for (int i = 0; i <= N ; i ++ ) a[i] = 0 ; | ||
for (int i = 1; i <= n ; i++ ) { | ||
cin >> a[i]; | ||
if ( i >= 3 && a[i] > 0) ans += a[i] ; | ||
} | ||
if (a[1] >= 0 && a[2] >= 0) ans += a[1] + a[2] ; | ||
else if (a[1] >= 0) ans += a[1] ; | ||
else if (a[1] + a[2] > 0) ans += a[1]+a[2] ; | ||
cout << ans << '\n'; | ||
|
||
} | ||
|
||
int main() { | ||
ios::sync_with_stdio(false); | ||
cin.tie(nullptr);cout.tie(nullptr); | ||
int T = 1 ; | ||
cin >> T ; | ||
while (T--) { | ||
AC(); | ||
} | ||
return 0; | ||
} |
Binary file not shown.