// UVa 11559 - Event Planning #include <iostream> using namespace std; #define datatype unsigned long long int int main() { int n, h, w; datatype b; while (cin >> n >> b >> h >> w) { datatype sol = b + 1; for (int i = 0; i < h; i++) { datatype p; cin >> p; bool consider = false; for (int j = 0; j < w; j++) { int a; cin >> a; if (a >= n) consider = true; } if (consider && p * n < sol) sol = p * n; } if (sol <= b) cout << sol << endl; else cout << "stay home" << endl; } return 0; }
No comments:
Post a Comment