Tonight, I watched the movie All night, downloaded a whole night's $gta4$ (13G ... ), the recent thunder seems to be very not to force, download speed is very slow, plus today exam six level, listening really kneeling dead-. -,
Do a $usaco$ before going to bed, seldom do the problem recently Qaq
=========================== Gorgeous theme split-line ===========================
The direct enumeration of violence, let $i$ cycle from the $1$~$83$, each time assuming the minimum value of $i$, and then at all the height of the $hill$ there to determine the OK
/*id:jusonal1prog:skidesignlang:c++*/#include <iostream> #include <cstdio> #include <cstring># Include <cmath> #include <vector> #include <algorithm>using namespace std;const int maxn = 1111;int n; int A[maxn];int Main () {freopen ("skidesign.in", "R", stdin); Freopen ("Skidesign.out", "w", stdout); while (~SCANF ("%d", &n)) {int ans = 0x3f3f3f3f,tmp; for (int i = 1;i <= n;++i) scanf ("%d", &a[i]); for (int i = 1;i <= 100-17;++i) {tmp = 0; for (int j = 1;j <= n;++j) {if (A[j] < i) tmp + = (a[j]-i) * (a[j]-i); if (A[j] > i+17) tmp + = (A[J]-I-17) * (A[J]-I-17); } ans = min (Tmp,ans); } printf ("%d\n", ans); } return 0;}
Usaco 1.3 Ski Course Design