bishalbiswas

11559

Oct 24th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. int n,b,h,w,price;
  7. int seat;
  8.  
  9. while(scanf("%d %d %d %d",&n,&b,&h,&w)==4)
  10. {
  11. int ans=0;
  12.  
  13. for(int j=0;j<h;j++)
  14. {
  15.  
  16. scanf("%d",&price);
  17.  
  18. for(int i=0;i<w;i++)
  19. {
  20. scanf("%d",&seat);
  21. if(seat>=n)
  22. {
  23. if(ans==0)
  24. ans=price*n;
  25. else if(ans>(price*n))
  26. ans=price*n;
  27.  
  28.  
  29. }
  30.  
  31. }
  32.  
  33. }
  34.  
  35. if(ans<b)
  36. printf("%d\n",ans);
  37. else
  38. printf("stay home\n");
  39. }
  40. return 0;
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment