Submission #1453392
Source Code Expand
#include<bits/stdc++.h> #include<sstream> #include<ext/pb_ds/tree_policy.hpp> using namespace std; #define mod 1000000007 #define all(v) v.begin(),v.end() #define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++) #define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--) #define strep(it,v) for(it=v.begin();it!=v.end();++it) #define ii pair<pair<ll,ll>,pair<ll,ll> > #define MP make_pair #define pb push_back #define f first #define se second #define ll long long int #define vi vector<ll> #define rs resize int main() { std::ios::sync_with_stdio(false); int n,i,sum = 0,avg,a1 = 0,a2 = 0; cin>>n; int a[n]; rep(i,0,n) cin>>a[i],sum += a[i]; avg = sum/n; rep(i,0,n) { a1 = a1 + pow(a[i] - avg,2); a2 = a2 + pow(a[i] - avg - 1,2); } cout<<min(a1,a2); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Be Together |
User | Tarun_ |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 817 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 |