結果
問題 | No.143 豆 |
ユーザー |
|
提出日時 | 2019-10-14 10:26:48 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 606 bytes |
コンパイル時間 | 12,520 ms |
コンパイル使用メモリ | 391,024 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 11:21:18 |
合計ジャッジ時間 | 13,502 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
コンパイルメッセージ
warning: unused variable: `f` --> src/main.rs:13:9 | 13 | let f = &l1[2]; | ^ help: if this is intentional, prefix it with an underscore: `_f` | = note: `#[warn(unused_variables)]` on by default
ソースコード
use std::io::{self, Read}; fn read_stdin() -> Vec<String> { let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer).ok(); buffer.trim().split('\n').map(|s| s.to_string()).collect() } fn main() { let input = read_stdin(); let l1 = &input[0].split(' ').map(|s| s.parse::<usize>().unwrap()).collect::<Vec<usize>>(); let beans = *&l1[0] * *&l1[1]; let f = &l1[2]; let ages = *&input[1].split(' ').map(|s| s.parse::<usize>().unwrap()).sum::<usize>(); if beans < ages { println!("{}", -1); } else { println!("{}", beans - ages); } }