Submission #1054814

#TimeUsernameProblemLanguageResultExecution timeMemory
1054814FaustasKSafety (NOI18_safety)C++14
5 / 100
57 ms2924 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int M[n]; long long suma = 0; for(int i = 0; i<n; i++) { cin >> M[i]; suma += M[i]; } double liekana = suma%n; suma /= n; liekana /= n; liekana = round(liekana); int vidurkis = suma+liekana; sort(M, M+n); vidurkis = M[n/2]; //cout << vidurkis << endl; long long ats = 0; for(int i = 0; i<n; i++) { ats += abs(M[i] - vidurkis); //cout << ats << ' '; } cout << ats; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...