結果

問題 No.3073 Fraction Median
コンテスト
ユーザー umezo
提出日時 2025-03-22 05:29:49
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 180 ms / 2,500 ms
+ 497µs
コード長 516 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,410 ms
コンパイル使用メモリ 341,328 KB
実行使用メモリ 15,116 KB
最終ジャッジ日時 2026-10-27 14:27:57
合計ジャッジ時間 9,296 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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