Adding some more judges, here and there.
[andmenj-acm.git] / NEERC / business / business_gk_wa.java
blobbeb869882d59bb9c04a37edc5907259fe1d4811d
1 /* Prints 0 if ground floor is reachable */
3 import java.util.*;
4 import java.io.*;
6 class business_gk_wa {
7 static Scanner in;
8 static PrintWriter out;
10 void run() throws IOException {
11 int n = in.nextInt();
12 int m = in.nextInt();
14 int min = Integer.MAX_VALUE;
15 for (int i = 0; i < m; i++) {
16 int u = in.nextInt();
17 int d = in.nextInt();
19 for (int j = 0; j <= n; j++) {
20 int f = u * j - d * (n - j);
21 if (f >= 0) {
22 min = Math.min(min, f);
27 out.println(min);
30 public static void main(String[] args) throws Exception {
31 in = new Scanner(new File("business.in"));
32 out = new PrintWriter("business.out");
34 new business_gk_wa().run();
36 in.close();
37 out.close();