結果
問題 | No.180 美しいWhitespace (2) |
ユーザー |
![]() |
提出日時 | 2020-08-16 23:03:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 679 bytes |
コンパイル時間 | 1,604 ms |
コンパイル使用メモリ | 166,420 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 10:44:57 |
合計ジャッジ時間 | 2,987 ms |
ジャッジサーバーID (参考情報) |
judge3 / 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; }