Contest Duration: - (local time) (100 minutes) Back to Home

Submission #836267

Source Code Expand

Copy
```#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <queue>

using namespace std;

#define pb push_back
#define pbk pop_back
#define fs first
#define sc second
#define sz(s) ((int) (s).size())
#define all(x) (x).begin(), (x).end()
#define mt make_tuple
#define mp make_pair
#define next hunext
#define prev huprev

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int inf = 1e9;
const double pi = 4 * atan(1.0);
const double eps = 1e-9;
const int N = 111;

int a[N];

inline int sqr(int x) {
return x * x;
}

int main() {
#ifdef LOCAL42
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
scanf("%d", a + i);
}
int ans = inf;
for (int i = -100; i <= 100; ++i) {
int sum = 0;
for (int j = 0; j < n; ++j) {
sum += sqr(a[j] - i);
}
ans = min(ans, sum);
}
cout << ans << endl;
return 0;
}
```

#### Submission Info

Submission Time 2016-08-13 21:11:07+0900 C - Be Together sankear C++14 (GCC 5.4.1) 200 1361 Byte AC 4 ms 256 KB

#### Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:56:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", a + i);
^
```

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
 AC × 4
 AC × 15
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt AC 4 ms 256 KB
0_001.txt AC 4 ms 256 KB
0_002.txt AC 4 ms 256 KB
0_003.txt AC 4 ms 256 KB
1_004.txt AC 4 ms 256 KB
1_005.txt AC 4 ms 256 KB
1_006.txt AC 4 ms 256 KB
1_007.txt AC 4 ms 256 KB
1_008.txt AC 4 ms 256 KB
1_009.txt AC 4 ms 256 KB
1_010.txt AC 4 ms 256 KB
1_011.txt AC 4 ms 256 KB
1_012.txt AC 4 ms 256 KB
1_013.txt AC 4 ms 256 KB
1_014.txt AC 4 ms 256 KB