Submission #104585

#TimeUsernameProblemLanguageResultExecution timeMemory
104585HassoonySimfonija (COCI19_simfonija)C++17
44 / 110
53 ms2192 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod=(1e9+7); const ll inf=(1ll<<61); const int MX=1e5+9; int n,k,a[MX],x; int main(){ cin>>n>>k; for(int i=0;i<n;i++)scanf("%d",&a[i]); for(int i=0;i<n;i++)scanf("%d",&x),a[i]-=x; sort(a,a+n); x=a[(n-1)/2]; ll ans=0; for(int i=0;i<n;i++){ a[i]-=x; a[i]=abs(a[i]); } sort(a,a+n); for(int i=0;i<n-k;i++){ ans+=a[i]; } cout<<ans<<endl; }

Compilation message (stderr)

simfonija.cpp: In function 'int main()':
simfonija.cpp:11:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%d",&a[i]);
                         ~~~~~^~~~~~~~~~~~
simfonija.cpp:12:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%d",&x),a[i]-=x;
                         ~~~~~~~~~~~~~~^~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...