結果

問題 No.180 美しいWhitespace (2)
ユーザー 37zigen37zigen
提出日時 2020-04-02 05:34:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 213 ms / 5,000 ms
コード長 1,007 bytes
コンパイル時間 2,881 ms
コンパイル使用メモリ 74,196 KB
実行使用メモリ 42,848 KB
最終ジャッジ日時 2023-09-10 05:28:23
合計ジャッジ時間 11,541 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
39,840 KB
testcase_01 AC 122 ms
39,324 KB
testcase_02 AC 122 ms
39,416 KB
testcase_03 AC 125 ms
39,504 KB
testcase_04 AC 140 ms
39,820 KB
testcase_05 AC 174 ms
39,812 KB
testcase_06 AC 180 ms
40,252 KB
testcase_07 AC 184 ms
40,656 KB
testcase_08 AC 192 ms
41,012 KB
testcase_09 AC 211 ms
42,420 KB
testcase_10 AC 207 ms
41,736 KB
testcase_11 AC 209 ms
42,036 KB
testcase_12 AC 212 ms
42,420 KB
testcase_13 AC 209 ms
42,288 KB
testcase_14 AC 213 ms
41,348 KB
testcase_15 AC 212 ms
41,488 KB
testcase_16 AC 208 ms
41,996 KB
testcase_17 AC 207 ms
41,400 KB
testcase_18 AC 207 ms
41,696 KB
testcase_19 AC 207 ms
42,848 KB
testcase_20 AC 124 ms
39,544 KB
testcase_21 AC 124 ms
40,004 KB
testcase_22 AC 122 ms
39,612 KB
testcase_23 AC 122 ms
39,532 KB
testcase_24 AC 124 ms
39,552 KB
testcase_25 AC 119 ms
39,700 KB
testcase_26 AC 121 ms
39,988 KB
testcase_27 AC 121 ms
39,508 KB
testcase_28 AC 122 ms
39,540 KB
testcase_29 AC 120 ms
39,628 KB
testcase_30 AC 203 ms
41,612 KB
testcase_31 AC 205 ms
41,544 KB
testcase_32 AC 206 ms
42,488 KB
testcase_33 AC 207 ms
41,860 KB
testcase_34 AC 203 ms
41,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	long f(long[] A,long[] B,long x) {
		int n=A.length;
		long INF=Long.MAX_VALUE;
		long ret=INF,max=-INF,min=INF;
		for(int i=0;i<n;++i) {
			max=Math.max(max, A[i]+B[i]*x);
			min=Math.min(min, A[i]+B[i]*x);
		}
		return max-min;
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long[] A=new long[N];
		long[] B=new long[N];
		for(int i=0;i<N;++i) {
			A[i]=sc.nextLong();
			B[i]=sc.nextLong();
		}
		//f(left)>f(left+1)
		//f(right)<=f(right+1)
		long left=0,right=(long)1e9;
		while(right-left>1) {
			long middle=(right+left)/2;
			if(f(A,B,middle)<=f(A,B,middle+1)) {
				right=middle;
			}else {
				left=middle;
			}
		}
		System.out.println(right);
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

0