結果

問題 No.180 美しいWhitespace (2)
ユーザー wing3196wing3196
提出日時 2015-04-06 00:29:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 860 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 72,716 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 04:57:43
合計ジャッジ時間 1,669 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 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
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:47:8: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  printf("%d\n",ans);
  ~~~~~~^~~~~~~~~~~~

ソースコード

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;
	while(r-l>4){
		int c1 = (l*2+r)/3, c2 = (l+r*2)/3;
		int r1 = latte(c1), r2 = latte(c2);
		if(r1>=r2) r = c2;
		else l = c1;
	}
	if(l==0) l = 1;
	int ans, ma = LLONG_MIN;
	for(int i=l;i<=r;i++){
		int ret = latte(i);
		if(ma<ret){
			ma = ret; ans = i;
		}
	}
	printf("%d\n",ans);
	return 0;
}
0