結果
問題 |
No.2718 Best Consonance
|
ユーザー |
![]() |
提出日時 | 2024-04-06 02:33:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 873 bytes |
コンパイル時間 | 2,535 ms |
コンパイル使用メモリ | 202,820 KB |
最終ジャッジ日時 | 2025-02-20 22:20:17 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; int main() { ll n; cin >> n; ll N = 200001; vector<ll> B(N, 0); ll ans = 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}); } ll M = 400001; 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; }