結果

問題 No.180 美しいWhitespace (2)
ユーザー 沙耶花沙耶花
提出日時 2021-11-03 17:56:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 790 bytes
コンパイル時間 4,498 ms
コンパイル使用メモリ 254,872 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:27:37
合計ジャッジ時間 5,603 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
6,944 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 3 ms
6,940 KB
testcase_33 AC 3 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/istream:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/sstream:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/x86_64-pc-linux-gnu/bits/stdc++.h:127,
                 from main.cpp:2:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:43:8:
/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ostream:204:25: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized]
  204 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:35:19: note: 'x' was declared here
   35 |         long long x;
      |                   ^

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 2000000000
int n;
vector<long long> a,b;

long long get(long long x){
	long long M = 0,m = 1000000000000000005;
	rep(i,n){
		M = max(M,a[i]+b[i]*x);
		m = min(m,a[i]+b[i]*x);
	}
	return M-m;
}

int main(){	
	
	cin>>n;
	a.resize(n),b.resize(n);
	rep(i,n)cin>>a[i]>>b[i];
	
	long long l = 1,r = 1000000005;
	while(r-l>3){
		long long m0 = l + (r-l)/3;
		long long m1 = m0 + (r-l)/3;
		if(get(m0)<=get(m1))r = m1;
		else l = m0;
	}
	long long ans = 100000000000000000;
	long long x;
	for(long long i=l;i<=r;i++){
		if(ans > get(i)){
			x =i;
			ans = get(i);
		}
	}
	
	cout<<x<<endl;
	
	return 0;
	
}
0