結果

問題 No.180 美しいWhitespace (2)
ユーザー tubo28tubo28
提出日時 2015-04-06 00:33:24
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,382 bytes
コンパイル時間 1,394 ms
コンパイル使用メモリ 151,356 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 05:00:46
合計ジャッジ時間 20,234 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 12 ms
4,376 KB
testcase_05 AC 70 ms
4,376 KB
testcase_06 AC 264 ms
4,380 KB
testcase_07 AC 583 ms
4,380 KB
testcase_08 AC 1,227 ms
4,376 KB
testcase_09 TLE -
testcase_10 AC 4,960 ms
4,376 KB
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 #

#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int H,W;
int g[200][200];

int sign(int x){
    if(x==0) return 0;
    return x < 0 ? -1 : 1;
}

int inf = LLONG_MAX;
vi a,b;
int N;
int solve(int x){
    vi v(N);
    rep(i,N) v[i] = a[i]+b[i]*x;
    int M = v[0], m = v[0];
    rep(i,N){
        M = max(M,v[i]);
        m = min(m,v[i]);
    }
    if(x==1){
        dump(v);
    }
    return M-m;
}

signed main(){
    while(cin >> N){
        a.resize(N); b.resize(N);
        rep(i,N) cin >> a[i] >> b[i];
        pair<int,int> ans = mp(solve(1),1);
        dump(ans);
        rep(i,N)rep(j,i){
            int a1,a2,b1,b2;
            tie(a1,b1) = tie(a[i],b[i]);
            tie(a2,b2) = tie(a[j],b[j]);
            if(sign(a1-a2) == sign(b1-b2) || sign(b1-b2) == 0) continue;
            double x = - (a1-a2) / (b1-b2);
            for(int d=-3;d<=3;d++){
                int xx = ceil(x+d);
                if(xx <= 0) xx = 1;
                int t = solve(xx);
                ans = min(ans,mp(t,xx));
            }
            dump(ans);
        }
        // if(ans == inf) ans = 1;
        cout << ans.second << endl;
    }
}
0