Skip to content

Commit 2157bc9

Browse files
committed
add abc414d.rs
1 parent 3710238 commit 2157bc9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/abc/abc414d.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/** THIS IS AN OUTPUT FILE. NOT EDIT THIS FILE DIRECTLY. **/
2+
use proconio::input;
3+
use proconio::marker::*;
4+
use std::marker::PhantomData;
5+
use std::cmp::*;
6+
use std::collections::*;
7+
8+
fn main() {
9+
input! {
10+
n:usize,
11+
m:usize,
12+
mut x:[usize; n],
13+
}
14+
15+
x.sort();
16+
let mut memo = vec![];
17+
for i in 0..n-1 {
18+
memo.push(x[i+1] - x[i]);
19+
}
20+
21+
if m >= n-1 {
22+
println!("0");
23+
return;
24+
}
25+
26+
memo.sort();
27+
let mut result = 0usize;
28+
for i in 0..n-m {
29+
result += memo[i];
30+
}
31+
32+
println!("{}", result);
33+
}

0 commit comments

Comments
 (0)