My issue
-1
4 0
8 2
-1
5 0
0 10
The output is coming wrong
PLEASE HELPPP!!!
My code
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int x,y,n,r,i,j;
cin>>x>>y>>n>>r;
bool m=true;
for(j=n;j>0;j--){
for(i=0;i<n;i++){
if((i+j==n) & ( i*x)+(j*y)<=r){
m=false;
goto label;
break;
}
}
}
if(m)
{cout<<-1<<endl;}
label: {cout<<i<<" "<<j<<endl;}
}
return 0;
}
Problem Link: BURGERS2 Problem - CodeChef