結果

問題 No.143 豆
コンテスト
ユーザー ta60143
提出日時 2018-10-24 17:18:04
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 758 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 750 ms
コンパイル使用メモリ 184,632 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-03 14:00:33
合計ジャッジ時間 1,459 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::io;

fn main() {
    let mut input1 = String::new();
    let mut input2 = String::new();
    
    io::stdin().read_line(&mut input1).unwrap();
    let mut input1 = input1.trim().split_whitespace();
    let k: i32 = input1.next().unwrap().parse().unwrap();
    let n: i32 = input1.next().unwrap().parse().unwrap();
    let f: u32 = input1.next().unwrap().parse().unwrap();
    
    io::stdin().read_line(&mut input2).unwrap();
    let mut ages = input2.trim().split_whitespace();
    
    let mut num_beans: i32 = k * n;
    
    for _ in 0..f {
        num_beans -= ages.next().unwrap().parse::<i32>().unwrap();
        
        if num_beans < 0 {
            println!("-1");
            return;
        }
    }
    
    println!("{}", num_beans);
}
0