結果

問題 No.180 美しいWhitespace (2)
ユーザー wing3196wing3196
提出日時 2015-04-06 00:21:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 880 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 72,584 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 04:56:28
合計ジャッジ時間 1,899 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
using namespace std;
#define int long long

int N,A[1000],B[1000];

int latte(int c){
	int mi = LLONG_MAX, ma = LLONG_MIN;
	for(int i=0;i<N;i++){
		int size = A[i]+B[i]*c;
		mi = min(mi,size); ma = max(ma,size);
	}
	return (ma-mi)*-1;
}

signed main(){
	cin>>N;
	for(int i=0;i<N;i++) cin>>A[i]>>B[i];
	int l = 0, r = 1e9;
	//printf("%lld\n",latte(0)); return 0;
	while(true){
		int c1 = (l*2+r)/3, c2 = (l+r*2)/3;
		if(c2-c1<=1){
			l = c1; r = c2; break;
		}
		int r1 = latte(c1), r2 = latte(c2);
		if(r1>r2) r = c2;
		else if(r1<r2) l = c1;
		else{
			puts("1"); return 0;
		}
	}
	printf("%lld\n",(latte(l)>latte(r))?l:r);
	return 0;
}
0