結果
問題 | No.1015 おつりは要らないです |
ユーザー | fukafukatani |
提出日時 | 2020-04-03 21:50:19 |
言語 | Rust (1.83.0 + proconio) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,896 bytes |
コンパイル時間 | 11,765 ms |
コンパイル使用メモリ | 389,472 KB |
実行使用メモリ | 8,736 KB |
最終ジャッジ日時 | 2024-11-17 23:09:09 |
合計ジャッジ時間 | 16,217 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 TLE * 1 |
ソースコード
#![allow(unused_imports)] #![allow(non_snake_case)] use std::cmp::*; use std::collections::*; use std::io::Write; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let v = read_vec::<i64>(); let (n, mut x, mut y, mut z) = (v[0] as usize, v[1], v[2], v[3]); let mut a = read_vec::<i64>() .into_iter() .map(|x| x + 1) .collect::<Vec<_>>(); for i in 0..n { let zi = a[i] / 10000; let act_z = min(z, zi); a[i] -= act_z * 10000; z -= act_z; } // debug!(a, x, y, z); while z > 0 { a.sort(); a.reverse(); for i in 0..n { if a[i] > 0 && z > 0 { a[i] -= 10000; z -= 1; } } } let mut a = a.into_iter().filter(|&x| x > 0).collect::<Vec<_>>(); let n = a.len(); for i in 0..n { let yi = a[i] / 5000; let act_y = min(y, yi); a[i] -= act_y * 5000; y -= act_y; } while y > 0 { a.sort(); a.reverse(); for i in 0..n { if a[i] > 0 && y > 0 { a[i] -= 5000; y -= 1; } } } for num in a { if num > 0 { x -= (1000 + num - 1) / 1000; } } if x >= 0 { println!("Yes"); } else { println!("No"); } } fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }