Submission #1454467
Source Code Expand
#include<iostream> #include<algorithm> #include <string> #include<cstdio> #include<math.h> #include<stack> #include<cstring> #include<vector> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define EREP(i,n) for(int i=(n-1);i>=0;--i) #define D(n,retu) REP(i,n){cin>>retu[i];} #define mod 1000000007 using namespace std; typedef long long int ll; template<typename T> void fill_all(T& arr, const T& v) { arr = v; } template<typename T, typename ARR> void fill_all(ARR& arr, const T& v) { for (auto& i : arr) { fill_all(i, v); } } //------------------変数-----------------------// ll n, a[100],k,cnt=547283908723495053; string str; //-------------------関数----------------------// int main() { cin >> n; REP(i, n) { cin >> a[i]; } for (int i = -200; i <=200; i++) { ll mini=0; REP(j, n) { mini += pow(a[j]-i, 2); } cnt = min(cnt, mini); } cout << cnt << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Be Together |
User | keidaroo |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 958 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
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 |