Created
January 29, 2026 20:09
-
-
Save icub3d/0dd72334c2a2c1c763b6f3db8a71eb45 to your computer and use it in GitHub Desktop.
Kattis eventplanning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::{Read, stdin}; | |
| fn main() { | |
| let mut s = String::new(); | |
| stdin().read_to_string(&mut s).unwrap(); | |
| let mut ss = s.lines(); | |
| let mut ff = ss | |
| .next() | |
| .unwrap() | |
| .split_whitespace() | |
| .map(|f| f.parse::<usize>().unwrap()); | |
| let (n, b, _, _) = ( | |
| ff.next().unwrap(), | |
| ff.next().unwrap(), | |
| ff.next().unwrap(), | |
| ff.next().unwrap(), | |
| ); | |
| let mut min = usize::MAX; | |
| while let Some(p) = ss.next() { | |
| let p = p.parse::<usize>().unwrap(); | |
| let aa = ss | |
| .next() | |
| .unwrap() | |
| .split_whitespace() | |
| .map(|a| a.parse::<usize>().unwrap()) | |
| .collect::<Vec<_>>(); | |
| if aa.iter().all(|&a| a < n) { | |
| continue; | |
| } | |
| if n * p > b { | |
| continue; | |
| } | |
| min = min.min(n * p); | |
| } | |
| if min < b { | |
| println!("{min}"); | |
| } else { | |
| println!("stay home"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment