Submission #41273003
Source Code Expand
Copy
use proconio::input;fn main() {input! {n: usize,k: usize,a: [usize; n],}// let ans = a// .iter()// .copied()// .position(|a_i| a_i >= k)// .map(|i| i as i64)// .unwrap_or(-1);// println!("{}", ans);if a[n - 1] < k {println!("-1");return;}if a[0] >= k {
use proconio::input; fn main() { input! { n: usize, k: usize, a: [usize; n], } // let ans = a // .iter() // .copied() // .position(|a_i| a_i >= k) // .map(|i| i as i64) // .unwrap_or(-1); // println!("{}", ans); if a[n - 1] < k { println!("-1"); return; } if a[0] >= k { println!("0"); return; } let mut ok = n - 1; let mut ng = 0; while ok - ng > 1 { let mid = ng + (ok - ng) / 2; if a[mid] >= k { ok = mid; } else { ng = mid; } } let ans = ok; println!("{}", ans); }
Submission Info
Submission Time | |
---|---|
Task | A - 二分探索の練習問題 |
User | bouzuya |
Language | Rust (1.42.0) |
Score | 100 |
Code Size | 680 Byte |
Status | AC |
Exec Time | 14 ms |
Memory | 3584 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_001.txt, sample_002.txt |
All | sample_001.txt, sample_002.txt, data_001.txt, data_002.txt, data_003.txt, data_004.txt, data_005.txt, data_006.txt, data_007.txt, data_008.txt, data_009.txt, data_010.txt, data_011.txt, data_012.txt, data_013.txt, data_014.txt, data_015.txt, data_016.txt, data_017.txt, data_018.txt, data_019.txt, data_020.txt, sample_001.txt, sample_002.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
data_001.txt | AC | 12 ms | 3448 KB |
data_002.txt | AC | 2 ms | 2192 KB |
data_003.txt | AC | 8 ms | 3408 KB |
data_004.txt | AC | 11 ms | 3372 KB |
data_005.txt | AC | 12 ms | 3272 KB |
data_006.txt | AC | 12 ms | 2904 KB |
data_007.txt | AC | 3 ms | 2300 KB |
data_008.txt | AC | 6 ms | 2772 KB |
data_009.txt | AC | 13 ms | 3300 KB |
data_010.txt | AC | 3 ms | 2340 KB |
data_011.txt | AC | 7 ms | 2692 KB |
data_012.txt | AC | 8 ms | 3348 KB |
data_013.txt | AC | 8 ms | 3380 KB |
data_014.txt | AC | 14 ms | 3584 KB |
data_015.txt | AC | 5 ms | 2716 KB |
data_016.txt | AC | 9 ms | 3544 KB |
data_017.txt | AC | 6 ms | 2752 KB |
data_018.txt | AC | 2 ms | 2220 KB |
data_019.txt | AC | 7 ms | 2732 KB |
data_020.txt | AC | 5 ms | 2444 KB |
sample_001.txt | AC | 2 ms | 2016 KB |
sample_002.txt | AC | 1 ms | 2024 KB |