結果
| 問題 |
No.2718 Best Consonance
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-05 22:33:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,152 ms / 4,000 ms |
| コード長 | 662 bytes |
| コンパイル時間 | 2,304 ms |
| コンパイル使用メモリ | 201,480 KB |
| 最終ジャッジ日時 | 2025-02-20 21:47:14 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 36 |
ソースコード
#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;
}