# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
100324 | 2019-03-10T11:45:09 Z | AKaan37 | Simfonija (COCI19_simfonija) | C++17 | 121 ms | 7416 KB |
//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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 67 ms | 5104 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 81 ms | 5180 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 71 ms | 5192 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 3824 KB | Output is correct |
2 | Incorrect | 36 ms | 4468 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 121 ms | 7416 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 4464 KB | Output is correct |
2 | Incorrect | 38 ms | 4464 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 103 ms | 7408 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 75 ms | 4768 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 39 ms | 4440 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |