結果
| 問題 |
No.3073 Fraction Median
|
| コンテスト | |
| ユーザー |
遭難者
|
| 提出日時 | 2025-03-12 01:06:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 316 ms / 2,500 ms |
| コード長 | 823 bytes |
| コンパイル時間 | 2,306 ms |
| コンパイル使用メモリ | 198,744 KB |
| 実行使用メモリ | 14,996 KB |
| 最終ジャッジ日時 | 2025-03-20 02:02:04 |
| 合計ジャッジ時間 | 8,551 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 vector
template <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 = -1;
for (int i = 1; i < n; i++) {
ld val2 = c[i - 1];
val2 /= c[i];
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();
}
遭難者