結果

問題 No.180 美しいWhitespace (2)
ユーザー ぴろずぴろず
提出日時 2015-03-08 15:30:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 191 ms / 5,000 ms
コード長 896 bytes
コンパイル時間 1,828 ms
コンパイル使用メモリ 76,364 KB
実行使用メモリ 59,096 KB
最終ジャッジ日時 2023-09-06 21:37:08
合計ジャッジ時間 9,300 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
55,476 KB
testcase_01 AC 110 ms
55,472 KB
testcase_02 AC 113 ms
55,540 KB
testcase_03 AC 112 ms
55,424 KB
testcase_04 AC 120 ms
55,180 KB
testcase_05 AC 153 ms
55,516 KB
testcase_06 AC 162 ms
55,596 KB
testcase_07 AC 170 ms
55,636 KB
testcase_08 AC 169 ms
55,732 KB
testcase_09 AC 191 ms
58,472 KB
testcase_10 AC 178 ms
58,456 KB
testcase_11 AC 180 ms
58,424 KB
testcase_12 AC 180 ms
58,448 KB
testcase_13 AC 190 ms
58,404 KB
testcase_14 AC 190 ms
58,364 KB
testcase_15 AC 189 ms
58,560 KB
testcase_16 AC 187 ms
58,196 KB
testcase_17 AC 180 ms
58,316 KB
testcase_18 AC 186 ms
58,628 KB
testcase_19 AC 182 ms
58,324 KB
testcase_20 AC 108 ms
55,488 KB
testcase_21 AC 108 ms
55,196 KB
testcase_22 AC 116 ms
55,456 KB
testcase_23 AC 111 ms
55,524 KB
testcase_24 AC 105 ms
55,724 KB
testcase_25 AC 108 ms
55,460 KB
testcase_26 AC 108 ms
55,544 KB
testcase_27 AC 109 ms
55,404 KB
testcase_28 AC 117 ms
55,480 KB
testcase_29 AC 109 ms
55,576 KB
testcase_30 AC 180 ms
59,096 KB
testcase_31 AC 184 ms
58,528 KB
testcase_32 AC 179 ms
58,208 KB
testcase_33 AC 179 ms
58,504 KB
testcase_34 AC 184 ms
56,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package beautifulws;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		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();
		}
		System.out.println(solve(n,a,b));
	}

	public static long solve(int n,int[] a,int[] b) {
		long left = 1;
		long right = 1_000_000_010;
		while(left + 1 < right) {
			long x = (left + right) >> 1;
			if (f(x-1,n,a,b) > f(x,n,a,b)) {
				left = x;
			}else{
				right = x;
			}
		}
		return left;
	}

	public static long f(long x,int n,int[] a,int[] b) {
		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 h = a[i] + b[i] * x;
			max = Math.max(h, max);
			min = Math.min(h, min);
		}
		return max - min;
	}
}
0