結果
問題 |
No.1015 おつりは要らないです
|
ユーザー |
![]() |
提出日時 | 2020-04-03 23:52:17 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 1,623 bytes |
コンパイル時間 | 21,021 ms |
コンパイル使用メモリ | 381,372 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-17 23:18:49 |
合計ジャッジ時間 | 12,599 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
use std::cmp::min; //{{{ #[allow(unused_macros)] macro_rules! getl { ( $( $t:ty ),* ) => { { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let s = s.trim_end(); let mut ws = s.split_whitespace(); ($(ws.next().unwrap().parse::<$t>().unwrap()),*) } }; } #[allow(unused_macros)] macro_rules! getl_vec { ( $t:ty ) => { { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let s = s.trim_end(); s.split_whitespace().map(|x| x.parse().unwrap()).collect::<Vec<$t>>() } }; } //}}} fn main() { let (n, x, y, z) = getl!(usize, i64, i64, i64); let mut a = getl_vec!(i64); for i in 0..n { a[i] += 1; } let mut z = z; for i in 0..n { let q = min(a[i] / 10000, z); z -= q; a[i] -= 10000 * q; } a.sort(); a.reverse(); for i in 0..n { if a[i] == 0 { break; } if z > 0 { z -= 1; a[i] = 0; } } let mut y = y; for i in 0..n { let q = min(a[i] / 5000, y); y -= q; a[i] -= 5000 * q; } a.sort(); a.reverse(); for i in 0..n { if a[i] == 0 { break; } if y > 0 { y -= 1; a[i] = 0; } } let mut x = x; for i in 0..n { let q = (a[i] + 1000 - 1) / 1000; x -= q; } if x >= 0 { println!("Yes"); } else { println!("No"); } }