結果

問題 No.180 美しいWhitespace (2)
ユーザー yumakmcyumakmc
提出日時 2016-02-18 04:33:29
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,392 bytes
コンパイル時間 2,572 ms
コンパイル使用メモリ 161,328 KB
実行使用メモリ 10,184 KB
最終ジャッジ日時 2023-10-22 06:30:46
合計ジャッジ時間 8,475 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:55:9: warning: ‘from’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |         if (from != amin){
      |         ^~

ソースコード

diff #

#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;


vector<long long >as,bs;
long long check(const int tab){
	long long amin = as[0] + bs[0] * tab;
	long long amax = as[0] + bs[0] * tab;

	for (int i = 1; i < as.size(); ++i){
		long long len = as[i] + bs[i] * tab;
		amin = min(amin, len);
		amax = max(amax, len);
	}
	return amax-amin;
}
int main() {
	int N; cin >> N;
	as.resize(N);
	bs.resize(N);
	for (int i = 0; i < N; ++i){
		cin >> as[i] >> bs[i];
	}
	long long  amin = 0;
	long long amax = 1e9;
	{
		int num = 50;
		while (num--, num){
			long long amid0 = (amin * 2 + amax) / 3;
			long long amid1 = (amin + amax * 2) / 3;
			if (check(amid0) < check(amid1)){
				amax = amid1;
			}
			else{
				amin = amid0;
			}
		}
	}
	long long anslen = check(amin);
	for (int i = amin; i < amax; ++i){
		anslen = min(check(i), anslen);
	}
	long long from;
	for (int i = amin; i < amax; ++i){
		if (anslen == check(i)){
			from = i;
			break;
		}
	}
	if (from != amin){
		cout << from << endl;
		return 0;
	}else
	{
		long long  amin = 0;
		long long amax = from;
		int num = 50;
		while (amin+1!=amax){
			long long amid = (amin + amax) / 2;
			if (check(amid) == anslen){
				amax = amid;
			}
			else{
				amin = amid;
			}
		}
		cout << amax << endl;
	}
	return 0;
}
0