Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(int argc, char** argv) {
- int n,b,h,w;
- int p,a;
- int i,j;
- while(scanf("%d %d %d %d",&n,&b,&h,&w)==4){
- int cost=0;
- for(i=0;i<h;i++){
- scanf("%d",&p);
- for(j=0;j<w;j++){
- scanf("%d",&a);
- if(a>=n && n*p<=b){
- if(cost==0 || n*p<cost)
- cost=n*p;
- }
- }
- }
- printf(cost == 0? "stay home\n" : "%d\n", cost);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement