結果

問題 No.180 美しいWhitespace (2)
ユーザー h_nosonh_noson
提出日時 2016-03-15 17:40:43
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 742 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 60,440 KB
実行使用メモリ 9,748 KB
最終ジャッジ日時 2024-04-08 13:21:54
合計ジャッジ時間 12,938 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8

typedef long long ll;

int n;
ll a[1000], b[1000], c[1000];

ll f(ll x) {
    int i;
    rep (i,n) c[i] = a[i] + b[i] * x;
    return *max_element(c,c+n) - *min_element(c,c+n);
}

int main() {
    int i;
    ll r, l;
    cin >> n;
    rep (i,n) cin >> a[i] >> b[i];
    l = 1;
    r = 1e9;
    while (l < r) {
        ll m1 = (l*2+r) / 3;
        ll m2 = (l+r*2+1) / 3;
        if (f(m1) <= f(m2))
            r = m2;
        else
            l = m1+1;
    }
    cout << r << endl;
    return 0;
}
0