結果
| 問題 | No.825 賢いお買い物 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-05-28 00:16:50 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,177 bytes |
| 記録 | |
| コンパイル時間 | 14,231 ms |
| コンパイル使用メモリ | 401,716 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-17 15:37:16 |
| 合計ジャッジ時間 | 12,153 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 16 WA * 3 |
コンパイルメッセージ
warning: unused variable: `money`
--> src/main.rs:22:9
|
22 | let money = a + 10 * b;
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_money`
|
= note: `#[warn(unused_variables)]` on by default
warning: function `read_vec2` is never used
--> src/main.rs:14:4
|
14 | fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
| ^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: variable `howManyCoins` should have a snake case name
--> src/main.rs:23:9
|
23 | let howManyCoins = a + b;
| ^^^^^^^^^^^^ help: convert the identifier to snake case: `how_many_coins`
|
= note: `#[warn(non_snake_case)]` on by default
warning: variable `deltaCoins` should have a snake case name
--> src/main.rs:24:9
|
24 | let deltaCoins = howManyCoins - c;
| ^^^^^^^^^^ help: convert the identifier to snake case: `delta_coins`
ソースコード
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>().split_whitespace()
.map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
(0..n).map(|_| read_vec()).collect()
}
fn main() {
let v = read_vec::<i16>();
let (a, b, c) = (v[0], v[1], v[2]);
let money = a + 10 * b;
let howManyCoins = a + b;
let deltaCoins = howManyCoins - c;
if deltaCoins < -9 {
println!("Impossible");
return
}else if deltaCoins >= -9 && deltaCoins < 0{
println!("{}", 10 + deltaCoins);
}else if deltaCoins == 0 {
println!("{}", 0);
}else if deltaCoins > 0{
for i in 0..deltaCoins{
let j = deltaCoins - i;
if i <= b && j <= a{
println!("{}",i*10+j);
return
}
}
println!("Impossible");
}
}