Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define sz(a) (int)a.size()
- #define all(x) (x).begin(),(x).end()
- #define pb push_back
- #define mp make_pair
- #define ll long long
- #define f first
- #define s second
- #define y1 Emilia_Clarke
- #define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
- using namespace std;
- const int inf = (int)1e9;
- const int mod = (int)1e9 + 7;
- const int N = 200200;
- ll n;
- bool can(ll k){
- ll sum = n;
- ll cur = 0;
- while(1){
- if(sum <= k){
- cur += sum;
- sum -= sum;
- break;
- }
- else{
- sum -= k;
- cur += k;
- }
- if(sum/10 == 0){
- cur += sum;
- break;
- }
- else{
- sum -= sum/10;
- }
- }
- ll D = n / 2;
- if(n % 2) D++;
- return cur >= D;
- }
- int main(){dracarys
- cin >> n;
- ll l = 1;
- ll r = n;
- ll res = -1;
- while(l <= r){
- ll mid = (l + r) >> 1;
- if(can(mid)){
- res = mid;
- r = mid - 1;
- }
- else
- l = mid + 1;
- }
- cout << res;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement