結果
問題 |
No.3074 Divide Points Fairly
|
ユーザー |
|
提出日時 | 2025-03-28 21:40:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,591 bytes |
コンパイル時間 | 2,369 ms |
コンパイル使用メモリ | 207,240 KB |
実行使用メモリ | 7,320 KB |
最終ジャッジ日時 | 2025-03-28 21:40:17 |
合計ジャッジ時間 | 6,152 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; int total = 2 * N; vector<pair<int,int>> pts(total); for (int i = 0; i < total; i++){ cin >> pts[i].first >> pts[i].second; } vector<pair<int,int>> cand = { {1,0}, {0,1}, {1,1}, {1,-1}, {1,2}, {2,1}, {1,-2}, {2,-1}, {1,3}, {3,1}, {1,-3}, {3,-1}, {2,3}, {3,2}, {2,-3}, {3,-2}, {1,4}, {4,1}, {1,-4}, {4,-1} }; for(auto &p : cand){ int a = p.first, b = p.second; int maxScale = 100000; if(a != 0) maxScale = min(maxScale, 100000 / abs(a)); if(b != 0) maxScale = min(maxScale, 100000 / abs(b)); vector<long long> base(total); for (int i = 0; i < total; i++){ base[i] = (long long)a * pts[i].first + (long long)b * pts[i].second; } sort(base.begin(), base.end()); long long gap = base[N] - base[N - 1]; if(gap <= 0) continue; long long k_min = (2 + gap - 1) / gap; // 即 ceil(2 / gap) if(k_min < 1) k_min = 1; if(k_min <= maxScale){ int A = a * k_min, B = b * k_min; long long C = -(base[N - 1] * k_min + 1); cout << A << " " << B << " " << C; return 0; } } vector<int> xs(total); for (int i = 0; i < total; i++){ xs[i] = pts[i].first; } sort(xs.begin(), xs.end()); int A = 2, B = 0; long long C = -(2LL * xs[N - 1] + 1); cout << A << " " << B << " " << C; return 0; }