結果

問題 No.825 賢いお買い物
ユーザー iwotiwot
提出日時 2020-06-04 15:16:44
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 998 bytes
コンパイル時間 15,827 ms
コンパイル使用メモリ 392,108 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-06 18:38:23
合計ジャッジ時間 14,092 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 0 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 0 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 0 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn main() {
  let abc:Vec<i64> = read_vec();
  let a = abc[0];
  let b = abc[1];
  let c = abc[2];

  let mut ans = None;
  for a_use in 0i64..=a {
    let a_money = a_use;
    for b_use in 0i64..=b {
      let b_money = b_use * 10;
      for price in 1..=100 {
        let rest = price - a_money - b_money;
        if rest <= 0 {
          let t = rest.abs() / 10 + rest.abs() % 10;
          if a + b - a_use - b_use + t == c {
            if ans.is_none() {
              ans = Some(a_money+b_money+rest);
            } else if ans.unwrap() > a_money+b_money+rest {
              ans = Some(a_money+b_money+rest);
            }
          }
        }
      }
    }
  }
  if let Some(ans) = ans {
    println!("{:?}", ans);
  } else {
    println!("Impossible");
  }
}
0