Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define sz(a) (int)a.size()
  3. #define all(x) (x).begin(),(x).end()
  4. #define pb push_back
  5. #define mp make_pair
  6. #define ll long long
  7. #define f first
  8. #define s second
  9. #define y1 Emilia_Clarke
  10. #define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
  11. using namespace std;
  12.  
  13. const int inf = (int)1e9;
  14. const int mod = (int)1e9 + 7;
  15. const int N = 200200;
  16.  
  17.  
  18. ll n;
  19. bool can(ll k){
  20. ll sum = n;
  21. ll cur = 0;
  22. while(1){
  23. if(sum <= k){
  24. cur += sum;
  25. sum -= sum;
  26. break;
  27. }
  28. else{
  29. sum -= k;
  30. cur += k;
  31. }
  32. if(sum/10 == 0){
  33. cur += sum;
  34. break;
  35. }
  36. else{
  37. sum -= sum/10;
  38. }
  39. }
  40. ll D = n / 2;
  41. if(n % 2) D++;
  42. return cur >= D;
  43. }
  44. int main(){dracarys
  45. cin >> n;
  46. ll l = 1;
  47. ll r = n;
  48. ll res = -1;
  49. while(l <= r){
  50. ll mid = (l + r) >> 1;
  51. if(can(mid)){
  52. res = mid;
  53. r = mid - 1;
  54. }
  55. else
  56. l = mid + 1;
  57. }
  58. cout << res;
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement