結果
問題 | No.180 美しいWhitespace (2) |
ユーザー | Mister |
提出日時 | 2020-09-04 15:45:19 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,196 ms / 5,000 ms |
コード長 | 1,426 bytes |
コンパイル時間 | 862 ms |
コンパイル使用メモリ | 85,488 KB |
実行使用メモリ | 13,140 KB |
最終ジャッジ日時 | 2023-08-17 04:25:55 |
合計ジャッジ時間 | 7,634 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 5 ms
4,376 KB |
testcase_05 | AC | 15 ms
4,376 KB |
testcase_06 | AC | 43 ms
4,376 KB |
testcase_07 | AC | 90 ms
5,084 KB |
testcase_08 | AC | 157 ms
5,224 KB |
testcase_09 | AC | 102 ms
11,552 KB |
testcase_10 | AC | 102 ms
12,208 KB |
testcase_11 | AC | 1,095 ms
11,680 KB |
testcase_12 | AC | 1,196 ms
12,024 KB |
testcase_13 | AC | 917 ms
12,600 KB |
testcase_14 | AC | 452 ms
12,504 KB |
testcase_15 | AC | 211 ms
11,640 KB |
testcase_16 | AC | 157 ms
12,512 KB |
testcase_17 | AC | 127 ms
11,796 KB |
testcase_18 | AC | 112 ms
11,976 KB |
testcase_19 | AC | 105 ms
11,832 KB |
testcase_20 | AC | 2 ms
4,380 KB |
testcase_21 | AC | 2 ms
4,376 KB |
testcase_22 | AC | 1 ms
4,376 KB |
testcase_23 | AC | 1 ms
4,376 KB |
testcase_24 | AC | 2 ms
4,380 KB |
testcase_25 | AC | 1 ms
4,380 KB |
testcase_26 | AC | 2 ms
4,380 KB |
testcase_27 | AC | 2 ms
4,380 KB |
testcase_28 | AC | 1 ms
4,376 KB |
testcase_29 | AC | 2 ms
4,376 KB |
testcase_30 | AC | 90 ms
13,140 KB |
testcase_31 | AC | 90 ms
11,776 KB |
testcase_32 | AC | 2 ms
4,376 KB |
testcase_33 | AC | 47 ms
8,892 KB |
testcase_34 | AC | 47 ms
7,516 KB |
ソースコード
#include <iostream> #include <algorithm> #include <vector> using lint = long long; constexpr lint INF = 1LL << 60; void solve() { int n; std::cin >> n; std::vector<std::pair<lint, lint>> ps(n); for (auto& [a, b] : ps) std::cin >> b >> a; std::vector<lint> xs{1}; for (int i = 0; i < n; ++i) { auto [a1, b1] = ps[i]; for (int j = 0; j < n; ++j) { auto [a2, b2] = ps[j]; if (b1 >= b2) continue; lint ok = 1, ng = 1 << 30; // a1 * ok + b1 < a2 * ok + b2 while (ng - ok > 1) { auto mid = (ok + ng) / 2; if (a1 * mid + b1 < a2 * mid + b2) { ok = mid; } else { ng = mid; } } xs.push_back(ok); xs.push_back(ng); } } std::sort(xs.begin(), xs.end()); xs.erase(std::unique(xs.begin(), xs.end()), xs.end()); lint min = INF, xmin = 0; for (auto x : xs) { lint l = INF, r = -INF; for (auto [a, b] : ps) { lint y = a * x + b; l = std::min(l, y); r = std::max(r, y); } if (r - l < min) { min = r - l; xmin = x; } } std::cout << xmin << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }