Source Code
#include <bits/stdc++.h>
#define ll long long
#define pp push_back
#define ff first
#define ss second

using namespace std;

ll w,m,mm,h,r,l,ii,i1,jj,a,x[1000001],y[1000001],z,zz,g,aa,bb,b,c,d[100001],k,vis,kk,mod=998244353,q,inf=1e18;
ll T,i,j,n;
vector <ll> v[1000001],vv;
pair <ll,ll> p;
map <ll,ll> mp,mpp,mppp;
set <ll> see;
set <ll> se;
set <ll> :: iterator it,itt,it1;
string s,s2,s1,t;
char cc;

void bs(ll l,ll r)
{
    if(z>max(((l+r)/2)*a,(n-(l+r)/2)*b))
        z=max(((l+r)/2)*a,(n-(l+r)/2)*b);
    if(l>=r)
        return;
    if(((l+r)/2)*a > (n-(l+r)/2)*b)
        bs(l,(l+r)/2-1);
    else if(((l+r)/2)*a < (n-(l+r)/2)*b)
        bs((l+r)/2+1,r);
    else
        return;
}

int main()
{
    ios::sync_with_stdio(0);
    z=1e18;
    cin >> n >> a >> b;
    bs(c,n);
    cout << z;
    return 0;
}
/*


*/
Copy
Hurry up Khaled_Mardini
GNU G++11
15 ms
24.3 MB
Accepted