結果
| 問題 |
No.3073 Fraction Median
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-26 10:42:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,169 ms / 2,500 ms |
| コード長 | 730 bytes |
| コンパイル時間 | 575 ms |
| コンパイル使用メモリ | 81,908 KB |
| 実行使用メモリ | 276,396 KB |
| 最終ジャッジ日時 | 2025-03-26 10:43:06 |
| 合計ジャッジ時間 | 20,802 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
from math import gcd
class Fraction:
def __init__(self, x, y):
g = gcd(x, y)
self.x = x // g
self.y = y // g
def __lt__(self, other):
return self.x * other.y < other.x * self.y
def __le__(self, other):
return self.x * other.y <= other.x * self.y
def __gt__(self, other):
return self.x * other.y > other.x * self.y
def __ge__(self, other):
return self.x * other.y >= other.x * self.y
def __eq__(self, other):
return self.x * other.y == other.x * self.y
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = Fraction(0, 1)
for i in range(N - 1):
ans = max(Fraction(A[i], A[i + 1]), ans)
print(ans.x, ans.y)