結果
問題 | No.3073 Fraction Median |
ユーザー |
|
提出日時 | 2025-03-21 23:12:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 318 ms / 2,500 ms |
コード長 | 521 bytes |
コンパイル時間 | 2,470 ms |
コンパイル使用メモリ | 199,156 KB |
実行使用メモリ | 15,004 KB |
最終ジャッジ日時 | 2025-03-21 23:12:48 |
合計ジャッジ時間 | 8,610 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; #include<atcoder/modint> using namespace atcoder; using mint=modint998244353; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll N; cin>>N; vector<ll> A(N); for(int i=0;i<N;i++){ cin>>A[i]; } sort(A.begin(),A.end()); ll X=1e9;ll Y=1; for(int i=0;i<N-1;i++){ if(A[i]==A[i+1]){ cout<<1<<" "<<1<<endl; return 0; } if(A[i+1]*Y<=A[i]*X){ X=A[i+1]; Y=A[i]; } } ll G=gcd(X,Y); cout<<Y/G<<" "<<X/G<<endl; }