Introduction

This is my blog of programming, I take notes and leave codes of computer science problems I solved here. Be my guest to comment :)

Tuesday, November 13, 2012

uva 11559 - Event Planning



/*
Problem link
Easy Adhoc
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;

int n,b,h,w;

int main() {
 while (!cin.eof())
 {
  int m = 2000000000;
  cin >> n >> b >> h >> w;
  if (cin.eof()) break;
  for (int i=1; i<=h; i++)
  {
   int p,k;
   cin >> p;
   for (int j=1; j<=w; j++)
   {
    cin >> k;
    if (k>=n && n*p<m) m = n*p;
   }
   
  }
  if (m<=b) cout << m << endl;
  else cout << "stay home" << endl;
 }
 return 0;
}


1 comment: