fork download
  1. // Axeman aka acrolypse
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define pc(x) __builtin_popcount(x)
  5. #define vec vector<long long >
  6.  
  7. int main() {
  8. ios_base::sync_with_stdio(false);
  9. cin.tie(NULL);
  10.  
  11. // ʜᴏɢᴀ ᴊᴀʀᴜʀ ʜᴏɢᴀ
  12.  
  13. int testcases;
  14. cin >> testcases;
  15. while(testcases--) {
  16. int len;
  17. cin>>len;
  18. vec arr(len);
  19. for(auto &x : arr) cin>>x;
  20. long long num = arr[0];
  21. for(long long i = 1 ; i<len ; i++){
  22. if(arr[i]>num){
  23. if( (arr[i] - num)%2 != 0){
  24. num += (arr[i] - num)/2 + 1;
  25. }
  26. else{
  27. num+= (arr[i] - num)/2;
  28. }
  29. }
  30. }
  31. cout<<num<<endl;
  32.  
  33.  
  34.  
  35.  
  36.  
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5320KB
stdin
4
3
1 2 3
3
1 2 2
2
1 1000000000
10
3 8 6 7 4 1 2 4 10 1
stdout
3
2
500000001
9