結果
問題 | No.2736 About half |
ユーザー |
|
提出日時 | 2024-04-20 10:53:14 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 964 bytes |
コンパイル時間 | 13,663 ms |
コンパイル使用メモリ | 379,040 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 06:29:17 |
合計ジャッジ時間 | 12,567 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 |
コンパイルメッセージ
warning: function `read_vec2` is never used --> src/main.rs:27:4 | 27 | fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> { | ^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
ソースコード
fn main() { let nums: Vec<u32> = read_vec(); if about_half(nums) { println!("Yes") } else { println!("No") } } fn about_half(nums: Vec<u32>) -> bool { let (a, b) = (nums[0],nums[1]); a.max(b) <= 2 * a.min(b) } fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> { (0..n).map(|_| read_vec()).collect() } #[cfg(test)] mod test { use crate::about_half; #[test] fn testcases() { assert_eq!(about_half(vec![6, 6]), true); assert_eq!(about_half(vec![4, 8]), true); assert_eq!(about_half(vec![4, 9]), false); assert_eq!(about_half(vec![500, 250]), true); } }