fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int t;
  7. cin>>t;
  8.  
  9. for(int z=0;z<t;z++)
  10. {
  11. int n;
  12. cin>>n;
  13.  
  14. double a[n];
  15. //priority_queue<double,vector<double> > pq;
  16. priority_queue<double> pq;
  17.  
  18. for(int i=0;i<n;i++)
  19. {
  20. double x;
  21. cin>>x;
  22. pq.push(x);
  23. }
  24.  
  25. while(pq.size()!=1)
  26. {
  27. double x = pq.top();
  28. pq.pop();
  29. double y = pq.top();
  30. pq.pop();
  31. pq.push((x+y)/2);
  32. }
  33.  
  34. //cout<<pq.top()<<"\n";
  35. printf("%.10f\n",pq.top());
  36. //cout<<setprecision(10)<<pq.top()<<"\n";
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0s 4404KB
stdin
2
2
9 3
3
3 2 9
stdout
6.0000000000
4.0000000000