結果
問題 | No.1715 Dinner 2 |
ユーザー | fukafukatani |
提出日時 | 2021-10-22 23:33:43 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,149 bytes |
コンパイル時間 | 13,331 ms |
コンパイル使用メモリ | 386,984 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-23 08:11:28 |
合計ジャッジ時間 | 15,191 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 0 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | AC | 63 ms
6,944 KB |
testcase_12 | AC | 50 ms
6,944 KB |
testcase_13 | AC | 42 ms
6,940 KB |
testcase_14 | AC | 53 ms
6,940 KB |
testcase_15 | AC | 55 ms
6,940 KB |
testcase_16 | AC | 46 ms
6,944 KB |
testcase_17 | AC | 33 ms
6,944 KB |
testcase_18 | AC | 1 ms
6,940 KB |
testcase_19 | AC | 1 ms
6,944 KB |
testcase_20 | AC | 1 ms
6,940 KB |
testcase_21 | AC | 1 ms
6,940 KB |
testcase_22 | AC | 1 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | AC | 1 ms
6,944 KB |
testcase_25 | AC | 6 ms
6,944 KB |
testcase_26 | AC | 5 ms
6,944 KB |
testcase_27 | AC | 5 ms
6,940 KB |
testcase_28 | AC | 6 ms
6,944 KB |
testcase_29 | AC | 6 ms
6,944 KB |
testcase_30 | AC | 6 ms
6,940 KB |
testcase_31 | AC | 7 ms
6,940 KB |
testcase_32 | AC | 77 ms
6,940 KB |
testcase_33 | AC | 81 ms
6,944 KB |
testcase_34 | AC | 89 ms
6,944 KB |
testcase_35 | AC | 86 ms
6,940 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
コンパイルメッセージ
warning: unused variable: `i` --> src/main.rs:23:9 | 23 | for i in 0..n { | ^ help: if this is intentional, prefix it with an underscore: `_i` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `ng` --> src/main.rs:55:14 | 55 | let (ok, ng) = binary_search(-(d as i64) * 1000000 - 1, 0, criterion); | ^^ help: if this is intentional, prefix it with an underscore: `_ng`
ソースコード
#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[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::<usize>(); let (n, d) = (v[0], v[1]); let mut negs = vec![]; for i in 0..n { let v = read_vec::<i64>(); let (p, q) = (v[0], v[1]); negs.push((p, q)); } let criterion = |mid: i64| -> bool { let mut used = n; let mut cur = 0; for _ in 0..d { let mut max_next = -std::i64::MAX; let mut max_i = n; for (i, &(p, q)) in negs.iter().enumerate() { if i == used { continue; } if cur - p >= mid { if max_next < cur + q - p { max_next = cur + q - p; max_i = i; } } } if max_next < mid { return false; } cur = max_next; used = max_i; } true }; let (ok, ng) = binary_search(-(d as i64) * 1000000 - 1, 0, criterion); println!("{}", ok); } type Input = i64; fn binary_search<F>(lb: Input, ub: Input, criterion: F) -> (Input, Input) where F: Fn(Input) -> bool, { assert_eq!(criterion(lb), true); assert_eq!(criterion(ub), false); let mut ok = lb; let mut ng = ub; while ng - ok > 1 { let mid = (ng + ok) / 2; if criterion(mid) { ok = mid; } else { ng = mid; } } (ok, ng) } 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() }