結果
問題 |
No.3067 +10 Seconds Clock
|
ユーザー |
|
提出日時 | 2025-03-22 00:18:15 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 277 ms / 2,000 ms |
コード長 | 940 bytes |
コンパイル時間 | 12,714 ms |
コンパイル使用メモリ | 403,064 KB |
実行使用メモリ | 9,088 KB |
最終ジャッジ日時 | 2025-03-22 00:18:33 |
合計ジャッジ時間 | 16,354 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
use proconio::input; use std::collections::BTreeSet; use proconio::marker::Usize1; fn main() { input! { n: usize, t: usize, a: [usize; n - 1], k: usize, x: [Usize1; k] } let x: BTreeSet<_> = x.into_iter().collect(); if !ok(k, t, &a, &x) { println!("-1"); return; } let mut l = -1; let mut r = k as isize; while l + 1 < r { let m = (l + r) as usize / 2; if ok(m, t, &a, &x) { r = m as isize; } else { l = m as isize; } } println!("{}", r); } fn ok(mut m:usize, t:usize, a:&Vec<usize>, x:&BTreeSet<usize>) -> bool { let mut now = t; let mut res = true; for i in 0..a.len() { if x.contains(&i) && m > 0 { now += 10; m -= 1; } res &= now > a[i]; if !res { break } now -= a[i]; } res }