結果
問題 | No.2386 Udon Coupon (Easy) |
ユーザー | あさくち |
提出日時 | 2023-07-21 22:16:39 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,539 bytes |
コンパイル時間 | 15,245 ms |
コンパイル使用メモリ | 379,008 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 23:46:21 |
合計ジャッジ時間 | 15,426 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
// #[proconio::fastout] fn main() { let mut n: usize = input_value(); let (a, b, c) = input_tuple::<usize>(); // 30 枚使う let mut list: Vec<usize> = vec![10 * a, 6 * b, 3 * c]; list.sort(); let mut result = 0_usize; if n > 100 { result += ((n / 30) - 2) * list[2]; n %= 30; n += 60; } let mut rest = 0; // println!("rest n {}", n); for i in 0..=30 { for j in 0..=30 { for k in 0..=30 { // println!("{} {} {} {}", i, j, k, i * a + j * b + k * c); if i * 3 + j * 5 + k * 10 <= n { rest = rest.max(i * a + j * b + k * c); } } } } println!("{}", result + rest); } fn input_value<T>() -> T where T: std::str::FromStr, <T as std::str::FromStr>::Err: std::fmt::Debug, { let stdin = std::io::stdin(); let mut buf = String::new(); stdin.read_line(&mut buf).unwrap(); buf = buf.trim_end().to_owned(); let n = buf.parse().unwrap(); n } fn input_tuple<T>() -> (T, T, T) where T: std::str::FromStr, <T as std::str::FromStr>::Err: std::fmt::Debug, { let stdin = std::io::stdin(); let mut buf = String::new(); stdin.read_line(&mut buf).unwrap(); buf = buf.trim_end().to_owned(); let mut iter = buf.split_whitespace(); let n = iter.next().unwrap().parse().unwrap(); let m = iter.next().unwrap().parse().unwrap(); let l = iter.next().unwrap().parse().unwrap(); (n, m, l) }