Source Code
#include <bits/stdc++.h>

using namespace std;


#define  all(a)   a.begin(), a.end()
#define  endl  '\n'
#define  ll long long
#define  set(a) fixed << setprecision(a)


int arr[1000];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t,x,y,c=0,b=0;
    string s;
    cin >>t>>x>>y;
    if(x>y)
        swap(x,y);
    if(x*t<y)
        cout<<x*t;
    else
    {while(t>0)
    {
        c+=x;
        t--;
        b+=y;
        t--;
        if(b-c>=x)
        {
            t-=(b-c)/x;
            c+=((b-c)/x)*x;
        }
    }
    cout<<min(c,b);
    }
    return 0;
}
Copy
Hurry up tahahussein143
GNU G++17
311 ms
708 KB
Wrong Answer