結果
問題 |
No.2718 Best Consonance
|
ユーザー |
![]() |
提出日時 | 2024-04-06 02:31:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 776 bytes |
コンパイル時間 | 2,372 ms |
コンパイル使用メモリ | 203,344 KB |
最終ジャッジ日時 | 2025-02-20 22:19:38 |
ジャッジサーバー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, a, b, ans = 0; cin >> n; const ll N = 200001, M = 400001; vector<ll> B(N, 0); rep(i, n) { 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; }