Source Code
#include<iostream>
using namespace std ;
 int main ()
 {
    long long  prob , a, b ;
    cin >> prob>>a>>b ; 
    
    if(a <= b) 
    {
        long long timer = 0 ;
        long long timerb =0 ;
        while (prob>0)
        {
            timer += a; 
            prob--;
            if(!prob)
                break;
            timerb+=a;
            if(timerb>=b)
            {
                timerb-=b;
                prob--;
                if(!prob)
                    break;
                
            }
        }
        cout<<timer<<endl;
    }
    else {
        long long timer = 0 ;
        long long timera =0 ;
        while (prob>0)
        {
            timer += b; 
            prob--;
            if(!prob)
                break;
            timera+=b;
            if(timera>=a)
            {
                timera-=a;
                prob--;
                if(!prob)
                    break;
                
            }
        }
        cout<<timer<<endl;
    }

     return 0 ; 
 }
Copy
Hurry up rubairshaid
GNU G++17
578 ms
700 KB
Wrong Answer