Skip to content

Commit 5b47436

Browse files
committed
typical90 one
1 parent e95710d commit 5b47436

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

Diff for: typical90/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ mod twenty_two;
4343
mod two;
4444

4545
fn main() {
46-
eighty_five::main();
46+
one::main();
4747
}

Diff for: typical90/src/one.rs

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
use std::rc::Rc;
2-
3-
use proconio::input;
4-
1+
#![allow(unused_imports)]
2+
use itertools::Itertools;
3+
use proconio::{
4+
fastout, input,
5+
marker::{Bytes, Chars, Isize1, Usize1},
6+
};
7+
use std::collections::{HashMap, HashSet};
8+
#[fastout]
59
pub fn main() {
610
input! {
7-
n :usize,
8-
l:u32,
11+
n:usize,
12+
l:usize,
913
k:usize,
10-
a :[u32;n]
14+
a:[usize;n],
1115
}
16+
1217
let mut left = 0;
1318
let mut right = l;
14-
let temp = a;
15-
1619
while right - left > 1 {
1720
let mid = (left + right) / 2;
18-
match cut(mid, &temp, l, k) {
19-
true => left = mid,
20-
false => right = mid,
21+
let mut count = 0;
22+
let mut prev = 0;
23+
for i in 0..n {
24+
if a[i] - prev >= mid && l - a[i] >= mid {
25+
count += 1;
26+
prev = a[i];
27+
}
2128
}
22-
}
23-
println!("{}", left);
24-
}
25-
26-
fn cut(target: u32, a: &[u32], l: u32, count: usize) -> bool {
27-
let mut prev = 0;
28-
let mut cut = 0;
29-
for i in a.iter() {
30-
if i - prev >= target && l - i >= target {
31-
cut += 1;
32-
prev = *i;
29+
if count >= k {
30+
left = mid;
31+
} else {
32+
right = mid;
3333
}
3434
}
35-
cut >= count
35+
println!("{}", left);
3636
}

0 commit comments

Comments
 (0)