Adding some more judges, here and there.
[andmenj-acm.git] / NEERC / business / business_gk_tl.java
blobde98f18dbc9affa27196334f5be04b430590e230
1 /* O(n * m) */
2 import java.util.*;
3 import java.io.*;
5 class business_gk_tl {
6 static Scanner in;
7 static PrintWriter out;
9 void run() throws IOException {
10 int n = in.nextInt();
11 int m = in.nextInt();
13 int min = Integer.MAX_VALUE;
14 for (int i = 0; i < m; i++) {
15 int u = in.nextInt();
16 int d = in.nextInt();
18 for (int j = 0; j <= n; j++) {
19 int f = u * j - d * (n - j);
20 if (f > 0) {
21 min = Math.min(min, f);
26 out.println(min);
29 public static void main(String[] args) throws Exception {
30 in = new Scanner(new File("business.in"));
31 out = new PrintWriter("business.out");
33 new business_gk_tl().run();
35 in.close();
36 out.close();