Submission #104583

#TimeUsernameProblemLanguageResultExecution timeMemory
104583HassoonySimfonija (COCI19_simfonija)C++17
0 / 110
1064 ms4400 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],b[MX],c[MX]; 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",&b[i]); for(int i=0;i<n;i++)c[i]=a[i]-b[i]; sort(c,c+n); int x=c[(n-1)/2]; ll ans=0; set<int>s; for(int i=0;i<n;i++){ c[i]-=x; s.insert(abs(c[i])); // cout<<c[i]<<" "; } while(k+1<n){ k++; ans+=*s.begin(); s.erase(s.begin()); } 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: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",&b[i]);
                         ~~~~~^~~~~~~~~~~~
#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...