Submission #527057

#TimeUsernameProblemLanguageResultExecution timeMemory
527057niloyrootSafety (NOI18_safety)C++14
5 / 100
35 ms3712 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]; } sort(a+1,a+n+1); ll ans=0; forp(i,1,n){ ans+=abs(a[i]-a[(n/2) + 1]); } cout<<ans<<newl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t=1; //cin>>t; while(t--)solve(); }

Compilation message (stderr)

safety.cpp: In function 'void solve()':
safety.cpp:18:8: warning: unused variable 'sum' [-Wunused-variable]
   18 |     ll sum=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...