Submission #1164949
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
signed main()
{
Int(n);
int ans = INF;
vi data(n);
rep(i, n) cin >> data[i];
for (int i = -100; i < 101; i++) {
int tmp = 0;
rep(j, n) {
tmp += (i - data[j]) * (i - data[j]);
}
ans = min(ans, tmp);
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time
2017-03-17 20:26:15+0900
Task
C - Be Together
User
Ti11192916
Language
C++14 (GCC 5.4.1)
Score
200
Code Size
1046 Byte
Status
AC
Exec Time
1 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:22:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
#define Int(x) int x; scanf("%lld", &x);
^
./Main.cpp:30:5: note: in expansion of macro ‘Int’
Int(n);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
200 / 200
Status
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
1 ms
256 KB
0_001.txt
AC
1 ms
256 KB
0_002.txt
AC
1 ms
256 KB
0_003.txt
AC
1 ms
256 KB
1_004.txt
AC
1 ms
256 KB
1_005.txt
AC
1 ms
256 KB
1_006.txt
AC
1 ms
256 KB
1_007.txt
AC
1 ms
256 KB
1_008.txt
AC
1 ms
256 KB
1_009.txt
AC
1 ms
256 KB
1_010.txt
AC
1 ms
256 KB
1_011.txt
AC
1 ms
256 KB
1_012.txt
AC
1 ms
256 KB
1_013.txt
AC
1 ms
256 KB
1_014.txt
AC
1 ms
256 KB