Submission #527045

#TimeUsernameProblemLanguageResultExecution timeMemory
527045niloyrootSafety (NOI18_safety)C++14
0 / 100
13 ms2604 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<ll>; using pl = pair<ll,ll>; #define pb push_back #define form(m,it) for(auto it=m.begin(); it!=m.end(); it++) #define forp(i,a,b) for(ll i=a; i<=b; i++) #define forn(i,a,b) for(ll i=a; i>=b; i--) #define newl '\n' #define ff first #define ss second const ll mod = 1000000007; void solve(){ ll n,h; cin>>n>>h; ll a[n+1]; ll sum=0; forp(i,1,n){ cin>>a[i]; sum+=a[i]; } sum/=n; ll ans1=0,ans2=0; forp(i,1,n){ ans1+=abs(a[i]-sum); ans2+=abs(a[i]-sum+1); } cout<<min(ans1,ans2)<<newl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t=1; //cin>>t; while(t--)solve(); }
#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...