結果

問題 No.180 美しいWhitespace (2)
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-04-07 08:41:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 217 ms / 5,000 ms
コード長 1,357 bytes
コンパイル時間 3,573 ms
コンパイル使用メモリ 74,580 KB
実行使用メモリ 58,972 KB
最終ジャッジ日時 2023-09-17 06:27:56
合計ジャッジ時間 11,213 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,920 KB
testcase_01 AC 126 ms
56,220 KB
testcase_02 AC 128 ms
55,680 KB
testcase_03 AC 130 ms
55,912 KB
testcase_04 AC 147 ms
55,628 KB
testcase_05 AC 173 ms
56,052 KB
testcase_06 AC 186 ms
56,380 KB
testcase_07 AC 184 ms
56,604 KB
testcase_08 AC 199 ms
56,516 KB
testcase_09 AC 216 ms
58,844 KB
testcase_10 AC 211 ms
58,812 KB
testcase_11 AC 208 ms
58,552 KB
testcase_12 AC 215 ms
58,580 KB
testcase_13 AC 214 ms
58,736 KB
testcase_14 AC 215 ms
58,728 KB
testcase_15 AC 217 ms
58,764 KB
testcase_16 AC 216 ms
58,960 KB
testcase_17 AC 217 ms
58,308 KB
testcase_18 AC 213 ms
58,428 KB
testcase_19 AC 212 ms
58,848 KB
testcase_20 AC 129 ms
56,052 KB
testcase_21 AC 128 ms
56,076 KB
testcase_22 AC 128 ms
56,152 KB
testcase_23 AC 127 ms
56,396 KB
testcase_24 AC 127 ms
55,712 KB
testcase_25 AC 127 ms
56,012 KB
testcase_26 AC 127 ms
55,860 KB
testcase_27 AC 127 ms
55,716 KB
testcase_28 AC 127 ms
55,960 KB
testcase_29 AC 129 ms
55,996 KB
testcase_30 AC 209 ms
58,920 KB
testcase_31 AC 199 ms
58,748 KB
testcase_32 AC 212 ms
58,584 KB
testcase_33 AC 216 ms
58,340 KB
testcase_34 AC 210 ms
58,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class No180 {
    
    static final Scanner in = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);

    static void solve() {
        n = in.nextInt();
        a = new int[n];
        b = new int[n];
        for (int i=0; i<n; i++) {
            a[i] = in.nextInt();
            b[i] = in.nextInt();
        }

        long l = 1, r = 1500000000;
        while (l+1 < r) {
            long x = (l+r)/2;
            if (f(x-1) > f(x)) l = x;
            else r = x;
        }
        out.println(l);
    }

    static int n;
    static int[] a, b;

    static long f(long x) {
        if (x <=0) return Long.MAX_VALUE;
        long max = Long.MIN_VALUE;
        long min = Long.MAX_VALUE;
        for (int i=0; i<n; i++) {
            long y = a[i] + b[i]*x;
            max = max(max,y);
            min = min(min,y);
        }
        return max - min;
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        solve();
        out.flush();

        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        in.close();
        out.close();
    }

    static void trace(Object... o) { System.out.println(deepToString(o));}
}
0