Skip to content

Commit

Permalink
adt_easy_20240307_2 e
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Mar 11, 2024
1 parent 2c0f388 commit baed17b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cargo-atcoder-1.70.0/contests/adt_easy_20240307_2/src/bin/e.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
// TODO
use proconio::{input, marker::Usize1};
use proconio::input;

fn main() {
input! {
n: usize,
a: [Usize1; n],
mut a: [usize; n],
};
let ans = n - a.len();
a.sort();
let sum = a.iter().sum::<usize>();
let avg = sum / n;
let avg2 = sum - avg * n;
let ans = vec![avg; n - avg2]
.into_iter()
.chain(vec![avg + 1; avg2])
.zip(a)
.map(|(x, y)| (x as i64 - y as i64).unsigned_abs() as usize)
.sum::<usize>()
/ 2;
println!("{}", ans);
}

0 comments on commit baed17b

Please sign in to comment.