結果

問題 No.2718 Best Consonance
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2024-04-05 22:33:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,050 ms / 4,000 ms
コード長 662 bytes
コンパイル時間 2,471 ms
コンパイル使用メモリ 203,956 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-04-10 10:52:30
合計ジャッジ時間 19,273 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 4 ms
6,940 KB
testcase_14 AC 731 ms
7,808 KB
testcase_15 AC 544 ms
7,168 KB
testcase_16 AC 584 ms
7,296 KB
testcase_17 AC 456 ms
6,940 KB
testcase_18 AC 633 ms
7,380 KB
testcase_19 AC 527 ms
6,944 KB
testcase_20 AC 713 ms
7,788 KB
testcase_21 AC 673 ms
7,552 KB
testcase_22 AC 694 ms
7,680 KB
testcase_23 AC 413 ms
6,940 KB
testcase_24 AC 754 ms
8,044 KB
testcase_25 AC 750 ms
8,064 KB
testcase_26 AC 744 ms
7,908 KB
testcase_27 AC 743 ms
7,876 KB
testcase_28 AC 744 ms
7,936 KB
testcase_29 AC 766 ms
7,892 KB
testcase_30 AC 745 ms
7,892 KB
testcase_31 AC 746 ms
7,936 KB
testcase_32 AC 750 ms
8,064 KB
testcase_33 AC 760 ms
7,936 KB
testcase_34 AC 3 ms
6,940 KB
testcase_35 AC 3 ms
6,944 KB
testcase_36 AC 1,050 ms
7,936 KB
testcase_37 AC 3 ms
6,940 KB
testcase_38 AC 1,001 ms
8,000 KB
testcase_39 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
	int N;
	cin >> N;
	using P = pair<ll, ll>;
	std::vector<P> A(N);
	for (auto& [a, b] : A) cin >> a >> b;
	sort(A.begin(), A.end(), [](P a, P b) {return a.first * a.second < b.first * b.second;});
	vector<ll> Bs(200020, (ll)1e18);
	ll ans = 0;
	for (int i = N - 1; i >= 0; i --) {
		auto& [a, b] = A[i];
		ll mi = (ll)1e18;
		for (ll x = 1; x * x <= a; x ++) {
			if (a % x) continue;
			mi = min(mi, Bs[x]);
			ll d = a / x;
			Bs[x] = min(Bs[x], d);
			if (d > x) {
				mi = min(mi, Bs[d]);
				Bs[d] = min(Bs[d], x);
			}
		}
		ans = max(ans, b / mi);
	}
	cout << ans << endl;
}
0