Help me in solving WEPCH problem

My issue

debug the code

My code

#include <iostream>;
using namespace std;
int main(){
    int t,b,m;
    cin>>t;
    while(t--){
        int h,x,y1,k,y2;
        int m,n,b,l;
        
        cin>>h>>x>>y1>>y2>>k;
        
        if(h%x==0){
            m = h/2; 
        }else{
            m = (h/2)+1;
        }
        
        
        n = y1 * k;
        if(n>=h){
            if(h % y1 ==0){
                 b = h/y1;
            }else{
                 b =(h/y1)+1;
            }
        }else{
             l = (h - (y1*k));
             if(l%y2==0){
                 b = k + (l/y1);
             }else{
                 b = k + (l/y1) +1;
             }

        }
        if(m>b){
        cout<<m<<endl;
    }else{
        cout<<b<<endl;
    }
        
    }
    
    return 0;
}

Problem Link: Weapon Choice Practice Coding Problem - CodeChef

#include <iostream>;
using namespace std;
int main(){
    int t,b,m;
    cin>>t;
    while(t--){
        int h,x,y1,k,y2;
        int m,n,b,l;
        
        cin>>h>>x>>y1>>y2>>k;
        
        if(h%x==0){
            m = h/x; 
        }else{
            m = (h/x)+1;
        }
        
        
        n = y1 * k;
        if(n>=h){
            if(h % y1 ==0){
                 b = h/y1;
            }else{
                 b =(h/y1)+1;
            }
        }else{
             l = (h - (y1*k));
             if(l%y2==0){
                 b = k + (l/y2);
             }else{
                 b = k + (l/y2) +1;
             }

        }
        if(m>b){
        cout<<b<<endl;
    }else{
        cout<<m<<endl;
    }
        
    }
    
    return 0;
}

There were some mistakes in your code which has been corrected in this one

1 Like

Thankyou so much bro