結果
| 問題 | 
                            No.180 美しいWhitespace (2)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-07-27 01:17:18 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 542 bytes | 
| コンパイル時間 | 2,012 ms | 
| コンパイル使用メモリ | 194,896 KB | 
| 最終ジャッジ日時 | 2025-01-12 06:42:07 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 31 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         int n; scanf("%d",&n);
      |                ~~~~~^~~~~~~~~
main.cpp:13:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         rep(i,n) scanf("%d%d",&a[i],&b[i]);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
const long long INF=1LL<<61;
int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d%d",&a[i],&b[i]);
	auto f=[&](lint x){
		lint mx=-INF,mn=INF;
		rep(i,n){
			mx=max(mx,a[i]+b[i]*x);
			mn=min(mn,a[i]+b[i]*x);
		}
		return mx-mn;
	};
	lint lo=1,hi=1e9;
	while(hi-lo>1){
		lint mi=(lo+hi)/2;
		if(f(mi)<=f(mi+1)) hi=mi;
		else               lo=mi;
	}
	printf("%lld\n",f(lo)<=f(hi)?lo:hi);
	return 0;
}