/*
ID:
PROG: skidesign
LANG: C++11
*/
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
freopen("skidesign.in", "r", stdin);
freopen("skidesign.out", "w", stdout);
int n;
int lower_bound, upper_bound;
int a[110] = {};
cin >> n;
for (int i = 0; i < n; i ++){
int t;
cin >> t;
a[t] += 1;
}
int ans = 10000000;
for (lower_bound = 0; lower_bound < 84; lower_bound ++){
upper_bound = lower_bound + 17;
int sum = 0;
for (int i = 0; i < 101; i ++){
if (a[i]){
if (i < lower_bound){
sum += a[i] * pow(i - lower_bound,2);
}
else if (i > upper_bound){
sum += a[i] * pow(i - upper_bound, 2);
}
}
}
if (sum < ans)
ans = sum;
}
cout << ans << endl;
return 0;
}
【USACO】Ski Course Design
最新推荐文章于 2018-09-01 23:39:48 发布