fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4.  
  5. signed main(){
  6. ios_base::sync_with_stdio(false);
  7. cin.tie(NULL);
  8. cout.tie(NULL);
  9. int t = 1;
  10. cin >> t;
  11. while(t--){
  12. int n;
  13. cin >> n;
  14. int a[n];
  15. for(int &i:a) cin >> i;
  16. sort(a, a + n);
  17. int ans = 0, i = 0, j = n - 1;
  18. while(i <= j){
  19. ans = max(ans, a[j] + a[i]);
  20. i++;
  21. j--;
  22. }
  23. cout << ans << '\n';
  24. }
  25. return 0;
  26. }
Runtime error #stdin #stdout 0.02s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty