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);
    while(t>0)
    {
        c+=x;
        t--;
        b+=y;
        t--;
        if(b-c>=x)
            t-=(b-c)/x;
    }
    cout<<max(c,b);
    return 0;
}

Copy
Hurry up tahahussein143
GNU G++17
312 ms
612 KB
Wrong Answer