CSES - Stick Lengths
Author: Danh Ta Chi Thanh
Appears In
In this problem, we are given an array with elements. We want to find the minimum cost to make all of the elements equal.
Solution
Another solution and some proofs
Here is the code implemenation for the easiest approach.
#include <bits/stdc++.h>using namespace std;//variables used for the current problemint n,median;vector<int> p;long long ans,cnt;void solve() {
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!