結果

問題 No.180 美しいWhitespace (2)
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-23 01:05:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,011 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 63,816 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 03:19:24
合計ジャッジ時間 1,555 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 = 1LL << 60;

ll 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 = 1000000001;
	for (int i = 0; i < 50; ++i){
		ll m1 = (l * 2 + r) / 3;
		ll m2 = (l + r * 2) / 3;
		if(search(m1) > search(m2)){//左側が高い
			l = m1;
		}else{//右側が高い
			r = m2;
		}
	}

	ll ans = l, minn = INF;
	// printf("k %d %d\n", l, r);
	for (int i = l; i <= r; ++i){
		ll t = search(i);
		if(minn > t){
			minn = t;
			ans = i;
		}
	}
	printf("%lld\n", ans);
	return 0;
}
0