結果
| 問題 |
No.3074 Divide Points Fairly
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-28 22:19:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,217 bytes |
| コンパイル時間 | 2,036 ms |
| コンパイル使用メモリ | 198,368 KB |
| 実行使用メモリ | 14,768 KB |
| 最終ジャッジ日時 | 2025-03-28 22:19:33 |
| 合計ジャッジ時間 | 10,262 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 7 WA * 19 TLE * 1 -- * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
random_device seed_gen;
mt19937 engine(seed_gen());
void solve() {
ll n;
cin >> n;
vector<ll> x(n * 2), y(n * 2);
rep(i, n * 2) cin >> x[i] >> y[i];
for (;;) {
const ll a = engine() % 200'001 - 100'000;
const ll b = engine() % 200'001 - 100'000;
if (a == 0 && b == 0)
continue;
auto check = [&](const ll c) -> bool {
ll res = 0;
rep(i, n * 2) if (y[i] > -a * x[i] - c) res++;
return res >= n;
};
ll ng = -ll(2e10) - 1, ok = ll(2e10);
while (ng + 1 < ok) {
ll c = (ng + ok) / 2;
if (check(c)) {
ok = c;
} else {
ng = c;
}
}
bool found = false;
ll res = 0;
rep(i, n * 2) {
if (y[i] == -a * x[i] - ok) {
found = true;
break;
} else if (y[i] > -a * x[i] - ok) {
res++;
}
}
if (!found && res == n) {
cout << a << ' ' << b << ' ' << ok << '\n';
return;
}
}
}
int main() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
int T = 1;
for (int t = 0; t < T; t++) {
solve();
}
return 0;
}