結果

問題 No.3074 Divide Points Fairly
ユーザー Zhiyuan Chen
提出日時 2025-03-28 21:37:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,271 bytes
コンパイル時間 1,981 ms
コンパイル使用メモリ 201,768 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-28 21:38:07
合計ジャッジ時間 7,653 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#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) maxScale = min(maxScale, 100000 / abs(a));
        if(b) maxScale = min(maxScale, 100000 / abs(b));
        for (int k = 1; k <= maxScale; k++){
            int A = a * k, B = b * k;
            vector<long long> vals(total);
            for (int i = 0; i < total; i++){
                vals[i] = (long long)A * pts[i].first + (long long)B * pts[i].second;
            }
            sort(vals.begin(), vals.end());
            if(vals[N] - vals[N - 1] >= 2){
                long long C = -(vals[N - 1] + 1);
                cout << A << " " << B << " " << C;
                return 0;
            }
        }
    }
	assert(1 == 0);
    return 0;
}
0