結果
問題 |
No.3073 Fraction Median
|
ユーザー |
![]() |
提出日時 | 2025-04-04 13:09:14 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 419 ms / 2,500 ms |
コード長 | 1,303 bytes |
コンパイル時間 | 3,722 ms |
コンパイル使用メモリ | 181,380 KB |
実行使用メモリ | 50,084 KB |
最終ジャッジ日時 | 2025-04-04 13:09:26 |
合計ジャッジ時間 | 11,168 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <set> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vmi = vector<mint>; using vvmi = vector<vmi>; using vvvmi = vector<vvmi>; #define all(a) (a).begin(), (a).end() #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) vll a; using p = pair<ll, ll>; int gcd(int x, int y){ if(x == 0){ return y; }else{ return gcd(y%x, x); } } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin >> n; rep(i, n){ ll b; cin >> b; a.push_back(b); } sort(all(a)); auto cmp = [](const p s, const p t){ return s.first * t.second < s.second *t.first; }; priority_queue<p, vector<p>, decltype(cmp)> pq; rep(i, n-1)pq.push({a[i], a[i+1]}); ll x = pq.top().first, y = pq.top().second; int g = gcd((int)x, (int)y); cout << x/g << " " << y/g << endl; return 0; }