結果

問題 No.3073 Fraction Median
ユーザー umezo
提出日時 2025-03-22 05:29:49
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 327 ms / 2,500 ms
コード長 516 bytes
コンパイル時間 3,779 ms
コンパイル使用メモリ 280,160 KB
実行使用メモリ 14,976 KB
最終ジャッジ日時 2025-03-22 05:30:01
合計ジャッジ時間 12,072 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  V<ll> A(n);
  rep(i,n) cin>>A[i];
  sort(ALL(A));
  ll x=A[0],y=A[1];
  for(int i=1;i<n-1;i++){
    if(x*A[i+1]<y*A[i]) x=A[i],y=A[i+1];
  }
  ll g=gcd(x,y);
  cout<<x/g<<" "<<y/g<<endl;

  return 0;
}
0