結果
問題 | No.505 カードの数式2 |
ユーザー |
|
提出日時 | 2023-01-14 00:10:55 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 781 bytes |
コンパイル時間 | 13,492 ms |
コンパイル使用メモリ | 374,952 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 20:02:59 |
合計ジャッジ時間 | 14,677 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
warning: unused import: `std::arch::x86_64::_mm_packus_epi16` --> src/main.rs:1:5 | 1 | use std::arch::x86_64::_mm_packus_epi16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
ソースコード
use std::arch::x86_64::_mm_packus_epi16; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec<isize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut cands = vec![a[0], a[0]]; for i in 1..n { let mut ncands = vec![]; for &v in cands.iter() { ncands.push(v + a[i]); ncands.push(v - a[i]); ncands.push(v * a[i]); if a[i] != 0 { ncands.push(v / a[i]); } } ncands.sort(); cands = vec![ncands[0], ncands[ncands.len()-1]]; } println!("{}", cands[1]); }