結果

問題 No.180 美しいWhitespace (2)
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-09-22 21:43:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,817 bytes
コンパイル時間 1,660 ms
コンパイル使用メモリ 171,476 KB
実行使用メモリ 10,268 KB
最終ジャッジ日時 2024-04-28 18:33:21
合計ジャッジ時間 19,563 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 11 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 231 ms
6,940 KB
testcase_07 AC 519 ms
6,940 KB
testcase_08 AC 1,100 ms
6,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

namespace {

    typedef long double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        auto i = vs.begin();
        os << "[" << *i;
        for (++i; i != vs.end(); ++i) os << " " << *i;
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    const ll INF = LLONG_MAX / 2LL;

    int N;
    vector<ll> A, B;
    void input() {
        cin >> N;
        A.resize(N);
        B.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> A[i] >> B[i];
        }
    }

    real C(ll x) {
        real m = 1e30;
        real M = 0; 
        for (int i = 0; i < N; i++) {
            m = min(m, A[i] + real(B[i]) * x);
            M = max(M, A[i] + real(B[i]) * x);
        }
        //cout << x << " -> " << M - m << endl;
        return M - m;
    }

    void solve() {
        if (N == 1) {
            cout << 0 << endl;
            return;
        }

        real len = C(1);
        ll t = 1;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (B[i] == B[j]) continue;
                real x = - (A[i] - A[j]) / real(B[i] - B[j]);
                if (x <= 0) continue;
                ll y = floor(x);
                for (ll dy = -2; dy <= 2; dy++) {
                    real p = C(y + dy);
                    if (len > p) {
                        len = p;
                        t = y + dy;
                    }
                }
            }
        }
        cout << t << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}

0