Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define ll long long
- using namespace std;
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int t,n;
- cin>>t;
- while(t--){
- cin>>n;
- vector<int> book(n);
- ll sum=0;
- for(int i=0;i<n;i++){
- cin>>book[i];
- sum+=book[i];
- }
- sort(book.begin(),book.end());
- cout<<max(sum,(ll)book[n-1]*2)<<"\n";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment