Submission #100324

#TimeUsernameProblemLanguageResultExecution timeMemory
100324AKaan37Simfonija (COCI19_simfonija)C++17
0 / 110
121 ms7416 KiB
//Sani buyuk Osman Pasa Plevneden cikmam diyor. //Bismillahirrahmanirrahim #include <bits/stdc++.h> using namespace std; typedef long long int lo; typedef pair< int,int > PII; #define fi first #define se second #define mp make_pair #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(lo i=1;i<=n;i++) #define mid (bas+son)/2 const lo MAX = -1000000000000000000; const lo MIN = 1000000000000000000; const lo inf = 1000000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 3000005; const lo mod = 1000000007; lo n,m,cev,b[li],a[li],k,mx=-inf; string s; vector<lo> v; vector<lo> vv; vector<lo> vec; map<lo,lo> mpp; int main(){ //~ freopen("simfonija.in.6a","r",stdin); scanf("%lld %lld",&n,&m); FOR{ scanf("%lld",&a[i]); } FOR{ scanf("%lld",&b[i]); mpp[abs(a[i]-b[i])]++; if(mpp[abs(a[i]-b[i])]==1) v.pb(abs(a[i]-b[i])); } lo say=-1; for(lo i=0;i<(lo)v.size();i++){ if(mpp[v[i]]>mx){cev=0;cev++;say=v[i];} if(mpp[v[i]]==mx && say!=v[i]){cev++;} mx=max(mx,mpp[v[i]]); } if(cev==1){ lo tut=0; FOR{ //~ cout<<mx<<endl; tut+=abs((a[i]+say)-b[i]); vec.pb(abs((a[i]+say)-b[i])); //~ cout<<a[i]<<" "<<b[i]<<endl; } sort(vec.begin(),vec.end()); reverse(vec.begin(),vec.end()); //~ cout<<vec[0]<<endl; //~ cout<<vec[1]<<endl; //~ cout<<vec[2]<<endl; for(lo i=0;i<m;i++){tut-=vec[i];} printf("%lld\n",tut); return 0; } for(lo i=0;i<(lo)v.size();i++){ if(mpp[v[i]]==mx) vv.pb(v[i]); } sort(vv.begin(),vv.end()); lo mx1=inf; vec.clear(); lo sayac=0; FOR{ //~ cout<<mx<<endl; sayac+=abs((a[i]+vv[(vv.size()-1)/2])-b[i]); vec.pb(abs((a[i]+vv[(vv.size()-1)/2])-b[i])); //~ cout<<a[i]<<" "<<b[i]<<endl; } for(lo i=0;i<m;i++){sayac-=vec[i];} mx1=min(mx1,sayac); vec.clear(); sayac=0; FOR{ //~ cout<<mx<<endl; sayac+=abs((a[i]+vv[(vv.size()-1)/2+1])-b[i]); vec.pb(abs((a[i]+vv[(vv.size()-1)/2+1])-b[i])); //~ cout<<a[i]<<" "<<b[i]<<endl; } for(lo i=0;i<m;i++){sayac-=vec[i];} mx1=min(mx1,sayac); vec.clear(); sayac=0; FOR{ //~ cout<<mx<<endl; sayac+=abs((a[i]+vv[(vv.size()-1)/2-1])-b[i]); vec.pb(abs((a[i]+vv[(vv.size()-1)/2]-1)-b[i])); //~ cout<<a[i]<<" "<<b[i]<<endl; } for(lo i=0;i<m;i++){sayac-=vec[i];} mx1=min(mx1,sayac); printf("%lld\n",mx1); return 0; }

Compilation message (stderr)

simfonija.cpp: In function 'int main()':
simfonija.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~
simfonija.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
simfonija.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&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...