結果

問題 No.180 美しいWhitespace (2)
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-22 22:01:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,077 bytes
コンパイル時間 661 ms
コンパイル使用メモリ 70,532 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 18:37:45
合計ジャッジ時間 1,868 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const ll INF = 1e12;

int n;
ll a[1010], b[1010];


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

int main(void){
	cin >> n;
	bool flag = true;
	rep(i, n){
		cin >> a[i] >> b[i];
		if(!(a[i] == 0 && b[i] == 0)) flag = false;
	}
	if(flag){
		printf("1\n"); return 0;
	}

	//下とつ
	ll l = 1, r = INF;
	while(r - l > 3){
		ll m1 = (l * 2 + r) / 3;
		ll m2 = (l + r * 2) / 3;
		if(search(m1) >= search(m2)){//左側が高い
			l = m1;
		}else{//右側が高い
			r = m2;
		}
	}

	// printf("%lld\n", l);
	vector<pair<ll, ll> > kai;
	ll p = l;
	if(l - 100 >= 1) p -= 100;
	else p = 1;
	for (ll i = p; i < p + 200; ++i){
		ll ret = search(i);
		kai.push_back(make_pair(ret, i));
	}
	sort(kai.begin(), kai.end());
	printf("%lld\n", kai[0].second);
	return 0;
}
0