結果

問題 No.3073 Fraction Median
ユーザー GOTKAKO
提出日時 2025-03-21 22:20:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 300 ms / 2,500 ms
コード長 560 bytes
コンパイル時間 2,227 ms
コンパイル使用メモリ 199,024 KB
実行使用メモリ 9,240 KB
最終ジャッジ日時 2025-03-21 22:20:58
合計ジャッジ時間 8,041 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<int> A(N);
    for(auto &a : A) cin >> a;
    sort(A.begin(),A.end());

    long long x = 0,y = 1;
    auto check = [&](long long a,long long b) -> bool {
        if((y-x)*b > (b-a)*y) return true;
        else return false; 
    };
    for(int i=0; i<N-1; i++) if(check(A.at(i),A.at(i+1))) x = A.at(i),y = A.at(i+1);
    

    long long g = gcd(x,y);
    x /= g; y /= g;
    cout << x << " " << y << "\n";
}
0