結果
| 問題 |
No.2718 Best Consonance
|
| コンテスト | |
| ユーザー |
shinchan
|
| 提出日時 | 2024-04-06 02:35:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 836 bytes |
| コンパイル時間 | 2,361 ms |
| コンパイル使用メモリ | 202,916 KB |
| 最終ジャッジ日時 | 2025-02-20 22:20:41 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
const ll N = 200001, M = 400001;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, ans = 0;
cin >> n;
vector<ll> B(N, 0);
rep(i, n) {
ll a, b;
cin >> a >> b;
ans = max(ans, min(b, B[a]));
B[a] = max(B[a], b);
}
vector<pair<ll, ll>> v;
for(ll i = 1; i < N; i ++) if(B[i]) v.push_back({i * B[i], i});
sort(all(v));
reverse(all(v));
vector<ll> exist(M, 0);
for(auto [Max, x] : v) {
for(ll i = x; i < M; i += x) if(exist[i]) {
ans = max(ans, Max / i);
break;
}
for(ll i = x; i < M; i += x) exist[i] = 1;
}
cout << ans << endl;
return 0;
}
shinchan