Usaco 1.3 Ski Course Design

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.