結果

問題 No.825 賢いお買い物
ユーザー iwotiwot
提出日時 2020-06-04 15:21:24
言語 Rust
(1.77.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,026 bytes
コンパイル時間 12,846 ms
コンパイル使用メモリ 377,768 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 18:45:43
合計ジャッジ時間 12,400 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 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 have = a + b * 100;

  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..=have {
        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