結果
| 問題 |
No.180 美しいWhitespace (2)
|
| ユーザー |
t8m8⛄️
|
| 提出日時 | 2015-04-07 08:40:12 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,357 bytes |
| コンパイル時間 | 3,379 ms |
| コンパイル使用メモリ | 78,020 KB |
| 実行使用メモリ | 59,252 KB |
| 最終ジャッジ日時 | 2024-07-04 03:34:01 |
| 合計ジャッジ時間 | 9,632 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 WA * 2 |
ソースコード
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 = 1000000000;
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));}
}
t8m8⛄️