blob: 9b0685b514ef08923607e89fd22e04422180cbd9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
use std::{
collections::VecDeque,
io::{stdin, Read},
};
fn main() {
let mut input = String::new();
stdin().lock().read_to_string(&mut input).unwrap();
let mut ints = input
.split_ascii_whitespace()
.map(|i| i.parse::<i32>().unwrap());
let mut get = || ints.next().unwrap();
for case in 0..get() {
let n = get();
let mut ds: VecDeque<_> = (0..n).map(|_| get()).collect();
let mut ans = 0;
let mut max = 0;
while !ds.is_empty() {
let f = ds.front().unwrap();
let b = ds.back().unwrap();
let d = if f < b {
ds.pop_front().unwrap()
} else {
ds.pop_back().unwrap()
};
if d >= max {
ans += 1;
max = d;
}
}
println!("Case #{}: {}", case + 1, ans);
}
}
|