結果

問題 No.3073 Fraction Median
ユーザー kenti
提出日時 2025-03-24 16:32:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 313 ms / 2,500 ms
コード長 495 bytes
コンパイル時間 2,318 ms
コンパイル使用メモリ 199,700 KB
実行使用メモリ 15,000 KB
最終ジャッジ日時 2025-03-24 16:32:20
合計ジャッジ時間 10,299 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll x = 0, y = 1;
    for (int i = 0; i + 1 < n; i++) {
        if (a[i] * y > a[i + 1] * x) {
            x = a[i];
            y = a[i + 1];
        }
    }
    cout << x / gcd(x, y) << " " << y / gcd(x, y) << "\n";
    return 0;
}
0