fork download
  1. #include <bits/stdc++.h>
  2. #define endl '\n'
  3. #define double long double
  4.  
  5. using namespace std;
  6.  
  7. const int N = 64;
  8. const int ITERATIONS = 5000;
  9.  
  10. int tests,current_case;
  11. int n,k;
  12. double u,p[N];
  13. double ans;
  14.  
  15. void message(int current_case) {
  16. //cerr<<"Case "<<current_case<<" solved!"<<endl;
  17. fprintf(stderr, "Case %d solved!\n", current_case);
  18. }
  19.  
  20. bool check(double v) {
  21. double sum=0.0;
  22. int i;
  23. for(i=1;i<=n;i++) if(p[i]<v) sum+=v-p[i];
  24. return (sum<=u);
  25. }
  26.  
  27. int main() {
  28. ios_base::sync_with_stdio(false);
  29. cin.tie(NULL);
  30. int i;
  31. double left,right,middle;
  32.  
  33. tests=1;
  34. //scanf("%d", &tests);
  35. cin>>tests;
  36. for(current_case=1;current_case<=tests;current_case++) {
  37. cin>>n>>k;
  38. cin>>u;
  39. for(i=1;i<=n;i++) {
  40. cin>>p[i];
  41. }
  42. left=0.0;
  43. right=1.01;
  44. for(i=1;i<=ITERATIONS;i++) {
  45. middle=(left+right)/2.0;
  46. if(check(middle)) left=middle;
  47. else right=middle;
  48. }
  49. ans=1.0;
  50. for(i=1;i<=n;i++) p[i]=max(p[i],right),ans*=p[i];
  51. cout<<"Case #"<<current_case<<": "<<setprecision(10)<<fixed<<ans<<endl;
  52.  
  53. MESSAGE:
  54. message(current_case);
  55. }
  56.  
  57. return 0;
  58. }
Success #stdin #stdout #stderr 0s 15240KB
stdin
Standard input is empty
stdout
Case #1: 1.0000000000
stderr
Case 1 solved!