結果
問題 |
No.3074 Divide Points Fairly
|
ユーザー |
![]() |
提出日時 | 2025-03-28 21:45:26 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,314 bytes |
コンパイル時間 | 3,295 ms |
コンパイル使用メモリ | 279,456 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-28 21:45:44 |
合計ジャッジ時間 | 9,428 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 TLE * 1 -- * 15 |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/modint> using namespace std; //using namespace atcoder; using ll = long long; //using mint = modint998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); /* y = ax+b ax-y+b = 0 aを乱択して半分に分けるbは二分探索で見つける。 直線上に点が存在しなければそれが答え。 */ ll N, M=2e10; cin >> N; vector<ll> x(N*2), y(N*2); for (int i=0; i<N*2; i++) cin >> x[i] >> y[i]; random_device seed; mt19937 engine(seed()); uniform_int_distribution<> dist(-100000, 100000); while(1){ ll a = dist(engine); ll l=-M-1, r=M, c; while(r-l>1){ c = (l+r)/2; ll cnt=0; for (int i=0; i<N*2; i++){ if (a*x[i]-y[i]+c>0) cnt++; } if (cnt >= N) r=c; else l=c; } ll cnt=0; bool f=1; for (int i=0; i<N*2; i++){ ll z = a*x[i]-y[i]+r; if (z == 0){ f = 0; break; } cnt += (z > 0); } if (f && (cnt == N)){ cout << a << " " << -1 << " " << r << endl; return 0; } } return 0; }