結果
問題 | No.143 豆 |
ユーザー |
|
提出日時 | 2020-07-10 16:53:33 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 849 bytes |
コンパイル時間 | 12,628 ms |
コンパイル使用メモリ | 387,084 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 11:33:03 |
合計ジャッジ時間 | 12,866 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
コンパイルメッセージ
warning: unnecessary parentheses around `if` condition --> src/main.rs:29:8 | 29 | if (mame_sum < eat_sum) { | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 29 - if (mame_sum < eat_sum) { 29 + if mame_sum < eat_sum { | warning: unused variable: `f` --> src/main.rs:24:9 | 24 | let f = knf[2]; | ^ help: if this is intentional, prefix it with an underscore: `_f` | = note: `#[warn(unused_variables)]` on by default warning: function `getline_as_u32_vec` is never used --> src/main.rs:7:4 | 7 | fn getline_as_u32_vec() -> Vec<u32> { | ^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
ソースコード
fn getline() -> String { let mut __ret = String::new(); std::io::stdin().read_line(&mut __ret).ok(); return __ret; } fn getline_as_u32_vec() -> Vec<u32> { let l = getline(); let nlv: Vec<_> = l.trim().split(' ').collect(); nlv.into_iter().map(|x| x.parse::<u32>().unwrap()).collect() } fn getline_as_u64_vec() -> Vec<u64> { let l = getline(); let nlv: Vec<_> = l.trim().split(' ').collect(); nlv.into_iter().map(|x| x.parse::<u64>().unwrap()).collect() } fn main() { let knf = getline_as_u64_vec(); let av = getline_as_u64_vec(); let k = knf[0]; let n = knf[1]; let f = knf[2]; let mame_sum: u64 = k * n; let eat_sum: u64 = av.iter().fold(0, |sum, a| sum + *a); if (mame_sum < eat_sum) { println!("-1") } else { println!("{}", mame_sum - eat_sum); } }