結果
問題 | No.3073 Fraction Median |
ユーザー |
![]() |
提出日時 | 2025-03-12 01:13:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 317 ms / 2,500 ms |
コード長 | 825 bytes |
コンパイル時間 | 2,153 ms |
コンパイル使用メモリ | 198,684 KB |
実行使用メモリ | 14,948 KB |
最終ジャッジ日時 | 2025-03-20 02:02:11 |
合計ジャッジ時間 | 8,748 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
// #define _GLIBCXX_DEBUG#include <bits/stdc++.h>using namespace std;#define rep(i, n) for (int i = 0; i < n; i++)#define SI(a) a.size()#define vec vectortemplate <typename T> bool chmin(T &x, T y) {if (y < x) {x = y;return true;}return false;}template <typename T> bool chmax(T &x, T y) {if (x < y) {x = y;return true;}return false;}void solve() {int n;cin >> n;using ld = long double;vec<long> c(n);rep(i, n) cin >> c[i];sort(c.begin(), c.end());int idx = -1;ld val = 1e20;for (int i = 1; i < n; i++) {ld val2 = c[i];val2 /= c[i - 1];if (val > val2) {val = val2;idx = i;}}long c1 = c[idx - 1], c2 = c[idx];long g = gcd(c1, c2);cout << c1 / g << " " << c2 / g << endl;}int main() {ios::sync_with_stdio(false);cin.tie(nullptr);solve();}