結果
問題 |
No.3073 Fraction Median
|
ユーザー |
|
提出日時 | 2025-03-22 00:08:59 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 995 ms / 2,500 ms |
コード長 | 968 bytes |
コンパイル時間 | 6,463 ms |
コンパイル使用メモリ | 332,252 KB |
実行使用メモリ | 15,028 KB |
最終ジャッジ日時 | 2025-03-22 00:09:22 |
合計ジャッジ時間 | 21,151 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge7 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i, a, n) for(ll i = a; i < n; i++) #define rrep(i, a, n) for(int i = a; i >= n; i--) #define inr(l, x, r) (l <= x && x < r) #define ll long long #define ld long double // using mint = modint1000000007; using mint = modint998244353; constexpr int IINF = 1001001001; constexpr ll INF = 1e18; template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;} template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;} ll gcd(ll a, ll b){ if(a%b == 0) return b; else return gcd(b, a%b); } int main(){ ll n; cin >> n; vector<ll> a(n); rep(i, 0, n) cin >> a[i]; sort(a.begin(), a.end()); pair<ll, ll> ans = {0, 1}; rep(i, 0, n-1){ int g = gcd(a[i], a[i+1]); if(a[i+1]*ans.first <= a[i]*ans.second){ ans = {a[i]/g, a[i+1]/g}; } } cout << ans.first << ' ' << ans.second << endl; return 0; }