結果

問題 No.180 美しいWhitespace (2)
ユーザー tubo28tubo28
提出日時 2015-04-06 00:33:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,156 ms / 5,000 ms
コード長 2,382 bytes
コンパイル時間 1,326 ms
コンパイル使用メモリ 151,648 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-17 05:02:32
合計ジャッジ時間 39,387 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 25 ms
4,380 KB
testcase_06 AC 88 ms
4,380 KB
testcase_07 AC 190 ms
4,376 KB
testcase_08 AC 392 ms
4,380 KB
testcase_09 AC 1,612 ms
4,376 KB
testcase_10 AC 1,575 ms
4,376 KB
testcase_11 AC 2,578 ms
4,376 KB
testcase_12 AC 2,961 ms
4,388 KB
testcase_13 AC 2,498 ms
4,376 KB
testcase_14 AC 2,785 ms
4,376 KB
testcase_15 AC 2,869 ms
4,376 KB
testcase_16 AC 2,524 ms
4,376 KB
testcase_17 AC 2,596 ms
4,384 KB
testcase_18 AC 2,470 ms
4,376 KB
testcase_19 AC 2,211 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3,153 ms
4,376 KB
testcase_31 AC 3,156 ms
4,380 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 1,585 ms
4,380 KB
testcase_34 AC 1,589 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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=-1;d<=1;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