結果
問題 | No.2718 Best Consonance |
ユーザー |
![]() |
提出日時 | 2024-07-11 01:40:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,008 ms / 4,000 ms |
コード長 | 1,243 bytes |
コンパイル時間 | 2,337 ms |
コンパイル使用メモリ | 202,876 KB |
最終ジャッジ日時 | 2025-02-22 02:54:47 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }#define all(x) (x).begin(),(x).end()#define fi first#define se second#define mp make_pair#define si(x) int(x.size())const int mod=998244353,MAX=200005,INF=15<<26;vector<int> yaku[MAX];ll mi[MAX];int main(){std::ifstream in("text.txt");std::cin.rdbuf(in.rdbuf());cin.tie(0);ios::sync_with_stdio(false);for(ll x=1;x<=200000;x++){for(ll y=x;y<=200000;y+=x){yaku[y].push_back(x);}mi[x]=INF;}ll N;cin>>N;vector<pair<ll,ll>> S(N);for(int i=0;i<N;i++) cin>>S[i].fi>>S[i].se;sort(all(S),[&](auto a,auto b){return a.fi*a.se<b.fi*b.se;});ll ans=0;for(int i=N-1;i>=0;i--){auto [a,b]=S[i];for(ll g:yaku[a]){if(mi[g]==INF) continue;ll L=a*mi[g]/g;chmax(ans,a*b/L);}for(ll g:yaku[a]){chmin(mi[g],a);}}cout<<ans<<endl;}