fork download
  1. #include <algorithm>
  2. #include <climits>
  3. #include <iostream>
  4. #include <set>
  5. #include <queue>
  6. #include <vector>
  7. #include <deque>
  8.  
  9.  
  10. #define ll long long
  11. #define x first
  12. #define y second
  13.  
  14.  
  15. using namespace std;
  16.  
  17.  
  18. bool fun(ll n,ll m){
  19. ll t=n;
  20. ll res=0;
  21. while(t>0){
  22. res+=min(t,m);
  23. t-=min(t,m);
  24. t-=(t/10);
  25. }
  26. if(2*res>=n) return true;
  27. return false;
  28. }
  29. void binary(ll n){
  30. ll l=1, r=n, m;
  31. while(l<=r){
  32. m=(r-l)/2+l;
  33. if( fun(n,m) ) r=m;
  34. else l=m+1;
  35. }
  36. cout<<m;
  37. }
  38.  
  39. int main() {
  40. ll n;
  41. cin>>n;
  42. binary(n);
  43. return 0;
  44. }
Time limit exceeded #stdin #stdout 5s 4368KB
stdin
45
stdout
Standard output is empty