C++ Saved Program: gifted-dog

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
  long N,B,H,W,p,a;
    //cout<<10/2<<endl;
    while(cin>>N){
        cin>>B>>H>>W;
        costo=B+1;
        for(int i=0;i<H;i++){
            cin>>p;
            for(int j=0;j<W;j++)
            {cin>>a;
                if(a>N && a*p<=B){
                    if(a*p < costo)
                        {costo=a*p;}
                }
            }    
        }
        if (costo==B+1)
            {cout<<"stay home"<<endl;}
        else
            {cout<<costo<<endl;}
        cout<<n<<endl;
    }
    return 0;
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs