結果

問題 No.143 豆
ユーザー mtwtkman
提出日時 2019-10-14 10:20:35
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 11,327 ms
コンパイル使用メモリ 390,836 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-23 09:16:02
合計ジャッジ時間 12,328 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

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);
    }
}
0