結果
| 問題 |
No.180 美しいWhitespace (2)
|
| ユーザー |
msm1993
|
| 提出日時 | 2020-10-23 16:10:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 679 bytes |
| コンパイル時間 | 1,619 ms |
| コンパイル使用メモリ | 167,548 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-21 10:17:43 |
| 合計ジャッジ時間 | 3,037 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
ll a[1010], b[1010];
ll f(int x) {
ll MIN = LLONG_MAX, MAX = LLONG_MIN;
for (int i = 0; i < N; i++) {
MIN = min(MIN, a[i] + b[i] * x);
MAX = max(MAX, a[i] + b[i] * x);
}
return MAX - MIN;
}
bool check(int x) {
return f(x - 1) > f(x);
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> a[i] >> b[i];
}
int ok = 1;
int ng = 1e9 + 10;
while (abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (check(mid)) {
ok = mid;
} else {
ng = mid;
}
}
cout << ok << endl;
}
msm1993