結果
問題 | No.825 賢いお買い物 |
ユーザー |
|
提出日時 | 2023-11-18 18:03:32 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,206 bytes |
コンパイル時間 | 12,617 ms |
コンパイル使用メモリ | 402,676 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-26 05:52:46 |
合計ジャッジ時間 | 13,982 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#![allow(unused_imports)]// use itertools::Itertools;// use proconio::input;// use proconio::marker::*;use std::cmp::Reverse;use std::collections::*;fn main() {input! {a:usize,b:usize,c:usize,}const INF: usize = std::usize::MAX;let mut ans = INF;let max_cost = a + 10 * b;for cost in 1..=max_cost {for x in cost..=max_cost {for i in 0..=x / 10 {if i <= b&& x - 10 * i <= a&& b - i + a - (x - 10 * i) + (x - cost) / 10 + (x - cost) % 10 == c{ans = ans.min(cost);}}}}if ans == INF {println!("Impossible");} else {println!("{}", ans);}}mod input {#[macro_export]macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}#[macro_export]macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}#[macro_export]macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}}