結果
問題 | No.2329 Nafmo、イカサマをする |
ユーザー | haihamabossu |
提出日時 | 2023-05-28 16:02:03 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,467 bytes |
コンパイル時間 | 13,449 ms |
コンパイル使用メモリ | 378,556 KB |
実行使用メモリ | 12,664 KB |
最終ジャッジ日時 | 2024-06-08 09:13:31 |
合計ジャッジ時間 | 15,886 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | WA | - |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 1 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 1 ms
5,376 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 119 ms
12,664 KB |
testcase_42 | WA | - |
ソースコード
pub mod lower_bound { pub fn lower_bound<T: Ord>(list: &[T], val: &T) -> usize { let mut l = 0; let mut r = list.len(); while l < r { let x = (l + r) / 2; match list[x].cmp(val) { std::cmp::Ordering::Less => { l = x + 1; } std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => { r = x; } } } l } pub fn upper_bound<T: Ord>(list: &[T], val: &T) -> usize { let mut l = 0; let mut r = list.len(); while l < r { let x = (l + r) / 2; match list[x].cmp(val) { std::cmp::Ordering::Less | std::cmp::Ordering::Equal => { l = x + 1; } std::cmp::Ordering::Greater => { r = x; } } } l } } pub mod scanner { pub struct Scanner { buf: Vec<String>, } impl Scanner { pub fn new() -> Self { Self { buf: vec![] } } pub fn new_from(source: &str) -> Self { let source = String::from(source); let buf = Self::split(source); Self { buf } } pub fn next<T: std::str::FromStr>(&mut self) -> T { loop { if let Some(x) = self.buf.pop() { return x.parse().ok().expect(""); } let mut source = String::new(); std::io::stdin().read_line(&mut source).expect(""); self.buf = Self::split(source); } } fn split(source: String) -> Vec<String> { source .split_whitespace() .rev() .map(String::from) .collect::<Vec<_>>() } } } use crate::{lower_bound::lower_bound, scanner::Scanner}; fn main() { let mut scanner = Scanner::new(); let t: usize = 1; for _ in 0..t { solve(&mut scanner); } } fn solve(scanner: &mut Scanner) { let n: usize = scanner.next(); let m: usize = scanner.next(); let k: usize = scanner.next(); let mut a = vec![0; n]; for i in 0..n { let x = scanner.next::<usize>(); a[i] = x; } if n == 0 || m == 0 { println!("0"); return; } let mut b = vec![vec![]; 4]; for i in 0..n { b[1].push(a[i]); for j in 0..n { b[2].push(a[i] + a[j]); for k in 0..n { b[3].push(a[i] + a[j] + a[k]); } } } for i in 1..=3 { b[i].sort(); } let mut ans = 0; for ki in 1..=k { if ki <= 3 { let mut i = lower_bound(&b[ki], &m); if i == b[ki].len() { i -= 1; } let x = b[ki][i]; if x <= m { ans = ans.max(x); } } else { for &x in b[3].iter() { if m <= x { break; } let mut i = lower_bound(&b[ki - 3], &(m - x)); if i == b[ki - 3].len() { i -= 1; } let y = b[ki - 3][i]; if x + y <= m { ans = ans.max(x + y); } } } } println!("{}", ans); }