Adding some more judges, here and there.
[and.git] / NEERC / business / business_gk_tl_cpp.cpp
blob49310621539df6890c7886309d25b9593b674f6b
1 /* O(n * m) */
2 #include <fstream>
4 using namespace std;
6 int main() {
7 ifstream in; in.open("business.in");
8 ofstream out; out.open("business.out");
10 int n, m;
11 in >> n >> m;
13 int result = 1000000000;
14 for (int i = 0; i < m; i++) {
15 int u, d;
16 in >> u >> d;
18 for (int j = 0; j <= n; j++) {
19 int f = u * j - d * (n - j);
20 if (f > 0) {
21 result = min(result, f);
25 out << result << endl;
27 in.close();
28 out.close();
30 return 0;