結果

問題 No.180 美しいWhitespace (2)
ユーザー wk1080idwk1080id
提出日時 2019-01-06 19:48:40
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,500 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 85,416 KB
実行使用メモリ 7,468 KB
最終ジャッジ日時 2023-08-15 16:19:27
合計ジャッジ時間 12,845 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
7,468 KB
testcase_01 AC 209 ms
4,380 KB
testcase_02 AC 139 ms
4,376 KB
testcase_03 AC 414 ms
4,380 KB
testcase_04 AC 4,426 ms
4,380 KB
testcase_05 TLE -
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<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}
int n;
vi a,b;

int f(int x){
    int ma = 0,mi = (ll)INF*INF;
    rep(i,n){
        ma = max(ma,a[i]+b[i]*x);
        mi = min(mi,a[i]+b[i]*x);
    }
    return ma-mi;
}

signed main(void) {
    int i,j;
    cin >> n;
    a = b = vi(n);
    rep(i,n) cin >> a[i] >> b[i];
    int lb = 1, ub = 2*INF;
    rep(_,10){
        int m1 = (lb+lb+ub)/3;
        int m2 = (lb+ub+ub)/3;
        if(f(m1) <= f(m2)) ub = m2;
        else lb = m1-1;
    }
    //cout << lb << " " << ub << endl;
    int ans = (ll)INF*INF;
    int x;
    loop(i,lb,ub+1){
        int t = f(i);
        if(ans > t){
            x = i;
            ans = t;
        }
    }
    cout << x << endl;
}
0