Advertisement
juanjo12x

UVA_11559_Event_Planning

Jun 6th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main(int argc, char** argv) {
  5.     int n,b,h,w;
  6.     int p,a;
  7.     int i,j;
  8.        
  9.       while(scanf("%d %d %d %d",&n,&b,&h,&w)==4){
  10.           int cost=0;
  11.         for(i=0;i<h;i++){
  12.             scanf("%d",&p);
  13.             for(j=0;j<w;j++){
  14.                 scanf("%d",&a);
  15.                 if(a>=n && n*p<=b){
  16.                     if(cost==0 || n*p<cost)
  17.                         cost=n*p;
  18.                 }
  19.             }
  20.         }
  21.          printf(cost == 0? "stay home\n" : "%d\n", cost);
  22.        }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement