結果
| 問題 |
No.750 Frac #1
|
| コンテスト | |
| ユーザー |
cra77756176
|
| 提出日時 | 2022-12-17 23:46:05 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 606 bytes |
| コンパイル時間 | 14,443 ms |
| コンパイル使用メモリ | 377,420 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 07:39:31 |
| 合計ジャッジ時間 | 15,879 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
struct Frac {
n: i64,
d: i64,
}
impl Frac {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
(other.d * self.n).cmp(&(self.d * other.n))
}
}
fn main() {
let mut xx = String::new();
std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok();
let xx: Vec<i64> = xx.split_whitespace().skip(1).flat_map(str::parse).collect();
let mut fractions: Vec<Frac> = xx.chunks(2).map(|x| Frac { n: x[0], d: x[1] }).collect();
fractions.sort_unstable_by(Frac::cmp);
fractions.reverse();
for f in fractions {
println!("{} {}", f.n, f.d);
}
}
cra77756176