125622024-12-23 12:25:094rt3xp02016. februárcpp17Accepted 1ms508 KiB
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n; cin >> n;
  vector<int> h(n);
  for(int &i: h) cin >> i;
  int mn=INT_MAX;
  for(int x=0;x<=83;x++){
    int s=0;
    for(int i: h){
      int tmp=0;
      if(i<x) tmp=x-i;
      else if(i>x+17) tmp=i-x-17;
      s+=tmp*tmp;
    }
    mn=min(mn,s);
  }
  cout << mn;
}
1 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
18
Expected output:
18
Checker output:
ok 1 number(s): "18"

2 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
298455
Expected output:
298455
Checker output:
ok 1 number(s): "298455"

3 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
208584
Expected output:
208584
Checker output:
ok 1 number(s): "208584"

4 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
107040
Expected output:
107040
Checker output:
ok 1 number(s): "107040"

5 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
210876
Expected output:
210876
Checker output:
ok 1 number(s): "210876"

6 - Accepted
Memory: 508KiB
Time: 1ms

Program's output:
280598
Expected output:
280598
Checker output:
ok 1 number(s): "280598"

7 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
206286
Expected output:
206286
Checker output:
ok 1 number(s): "206286"

8 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
54651
Expected output:
54651
Checker output:
ok 1 number(s): "54651"

9 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
88767
Expected output:
88767
Checker output:
ok 1 number(s): "88767"

10 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
9518
Expected output:
9518
Checker output:
ok 1 number(s): "9518"

11 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
427475
Expected output:
427475
Checker output:
ok 1 number(s): "427475"

12 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
419533
Expected output:
419533
Checker output:
ok 1 number(s): "419533"

13 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
250041
Expected output:
250041
Checker output:
ok 1 number(s): "250041"

14 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
478932
Expected output:
478932
Checker output:
ok 1 number(s): "478932"

15 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
291469
Expected output:
291469
Checker output:
ok 1 number(s): "291469"

16 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
204043
Expected output:
204043
Checker output:
ok 1 number(s): "204043"

17 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
53653
Expected output:
53653
Checker output:
ok 1 number(s): "53653"

18 - Accepted
Memory: 508KiB
Time: 1ms

Program's output:
333176
Expected output:
333176
Checker output:
ok 1 number(s): "333176"

19 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
47796
Expected output:
47796
Checker output:
ok 1 number(s): "47796"

20 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
154982
Expected output:
154982
Checker output:
ok 1 number(s): "154982"

21 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
134811
Expected output:
134811
Checker output:
ok 1 number(s): "134811"

22 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
323963
Expected output:
323963
Checker output:
ok 1 number(s): "323963"