Source Code
#include<iostream>
using namespace std ;
 int main ()
 {
    int prob , a, b ;
    cin >> prob>>a>>b ; 
    
    if(a <= b) 
    {
        int timer = 0 ;
        int 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 {
        int timer = 0 ;
        int 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
790 ms
512 KB
Wrong Answer