結果
問題 | No.507 ゲーム大会(チーム決め) |
ユーザー | hatoo |
提出日時 | 2017-10-13 22:37:02 |
言語 | Rust (1.77.0 + proconio) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,314 bytes |
コンパイル時間 | 13,581 ms |
コンパイル使用メモリ | 378,212 KB |
実行使用メモリ | 14,352 KB |
最終ジャッジ日時 | 2024-11-17 11:35:56 |
合計ジャッジ時間 | 54,524 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
9,100 KB |
testcase_01 | AC | 1 ms
10,624 KB |
testcase_02 | AC | 1 ms
10,624 KB |
testcase_03 | AC | 1 ms
8,980 KB |
testcase_04 | AC | 1 ms
10,532 KB |
testcase_05 | AC | 1 ms
8,960 KB |
testcase_06 | AC | 1 ms
10,624 KB |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | AC | 1 ms
5,248 KB |
testcase_18 | AC | 1 ms
5,248 KB |
testcase_19 | AC | 1 ms
5,248 KB |
testcase_20 | AC | 1 ms
14,352 KB |
ソースコード
#[allow(unused_imports)] use std::cmp::{max, min}; #[allow(unused_imports)] use std::collections::{HashMap, HashSet, BTreeSet}; mod util { use std::io::stdin; use std::str::FromStr; use std::fmt::Debug; #[allow(dead_code)] pub fn line() -> String { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().to_string() } #[allow(dead_code)] pub fn get<T: FromStr>() -> T where <T as FromStr>::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().parse().unwrap() } #[allow(dead_code)] pub fn gets<T: FromStr>() -> Vec<T> where <T as FromStr>::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse().unwrap()) .collect() } #[allow(dead_code)] pub fn get2<T: FromStr, U: FromStr>() -> (T, U) where <T as FromStr>::Err: Debug, <U as FromStr>::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), ) } #[allow(dead_code)] pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U) where <S as FromStr>::Err: Debug, <T as FromStr>::Err: Debug, <U as FromStr>::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), ) } } #[allow(unused_macros)] macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } } fn rank(k: usize, buddy: usize, a: &[usize]) -> usize { let t = k + buddy; let mut l = 0; let mut r = a.len() - 1; let mut cnt = 0; let mut skipped = false; while r > l { if !skipped && a[l] == buddy { l += 1; skipped = true; continue; } if !skipped && a[r] == buddy { r -= 1; skipped = true; continue; } if a[l] + a[r] > t { r -= 1; l += 1; cnt += 1; } else { l += 1; } } cnt } fn main() { let (n, m): (usize, usize) = util::get2(); let k: usize = util::get(); let mut a: Vec<usize> = (1..n).map(|_| util::get()).collect(); a.sort(); let mut scores = a.clone(); scores.dedup(); let mut up = scores .iter() .map(|&s| (n - rank(k, s, &a), s)) .collect::<Vec<_>>(); up.sort(); let res = up.binary_search(&(n - (m - 1), 0)); match res { Ok(i) => { println!("{}", up[i].1); } Err(i) => { if i == up.len() { println!("-1"); } else { println!("{}", up[i].1); } } } }