結果
問題 | No.180 美しいWhitespace (2) |
ユーザー | Grenache |
提出日時 | 2016-07-04 19:27:16 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 92 ms / 5,000 ms |
コード長 | 2,014 bytes |
コンパイル時間 | 4,485 ms |
コンパイル使用メモリ | 79,368 KB |
実行使用メモリ | 38,704 KB |
最終ジャッジ日時 | 2024-10-12 20:11:07 |
合計ジャッジ時間 | 8,237 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
36,628 KB |
testcase_01 | AC | 54 ms
37,244 KB |
testcase_02 | AC | 52 ms
36,936 KB |
testcase_03 | AC | 52 ms
37,024 KB |
testcase_04 | AC | 53 ms
37,184 KB |
testcase_05 | AC | 59 ms
36,876 KB |
testcase_06 | AC | 72 ms
37,924 KB |
testcase_07 | AC | 67 ms
37,684 KB |
testcase_08 | AC | 75 ms
38,048 KB |
testcase_09 | AC | 88 ms
38,336 KB |
testcase_10 | AC | 90 ms
38,040 KB |
testcase_11 | AC | 89 ms
38,248 KB |
testcase_12 | AC | 88 ms
38,124 KB |
testcase_13 | AC | 88 ms
38,596 KB |
testcase_14 | AC | 86 ms
38,460 KB |
testcase_15 | AC | 86 ms
38,368 KB |
testcase_16 | AC | 86 ms
38,636 KB |
testcase_17 | AC | 89 ms
38,596 KB |
testcase_18 | AC | 87 ms
38,340 KB |
testcase_19 | AC | 89 ms
38,620 KB |
testcase_20 | AC | 54 ms
37,288 KB |
testcase_21 | AC | 54 ms
37,064 KB |
testcase_22 | AC | 54 ms
37,000 KB |
testcase_23 | AC | 52 ms
36,628 KB |
testcase_24 | AC | 53 ms
36,872 KB |
testcase_25 | AC | 53 ms
36,980 KB |
testcase_26 | AC | 53 ms
36,964 KB |
testcase_27 | AC | 53 ms
37,288 KB |
testcase_28 | AC | 54 ms
36,748 KB |
testcase_29 | AC | 53 ms
36,824 KB |
testcase_30 | AC | 88 ms
38,264 KB |
testcase_31 | AC | 91 ms
38,704 KB |
testcase_32 | AC | 92 ms
38,220 KB |
testcase_33 | AC | 91 ms
38,548 KB |
testcase_34 | AC | 90 ms
38,488 KB |
ソースコード
import java.io.*; import java.util.*; public class Main_yukicoder180 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); } // 整数の三分探索 long l = 0; long r = 1_000_000_000; while (r - l > 1) { long mid = l + (r - l) / 2; if (f(mid + 1, a, b) - f(mid, a, b) >= 0) { r = mid; } else { l = mid; } } pr.println(r); pr.close(); sc.close(); } private static long f(long x, int[] a, int[] b) { long min = Long.MAX_VALUE; long max = Long.MIN_VALUE; for (int i = 0; i < a.length; i++) { min = Math.min(min, (long)a[i] + b[i] * x); max = Math.max(max, (long)a[i] + b[i] * x); } return max - min; } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }