Submission #101722

# Submission time Handle Problem Language Result Execution time Memory
101722 2019-03-19T15:33:25 Z mayhoubsaleh Simfonija (COCI19_simfonija) C++14
0 / 110
144 ms 3344 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;
ll n,k;
pair<ll,ll>a[100005];
bool mys(pair<ll,ll>a,pair<ll,ll>b){
    ll x=abs(a.first-a.second);
    ll y=abs(b.first-b.second);
    return x>y;
}
ll ans=0;
int main(){
    cin>>n>>k;
    for(ll i=0;i<n;i++){
        cin>>a[i].first;
    }
    for(ll i=0;i<n;i++){
        cin>>a[i].second;
    }
    sort(a,a+n,mys);
    ll mid1=0,mid2=0;
    for(ll i=k;i<n;i++){
        mid1+=a[i].first;
        mid2+=a[i].second;
    }
    ll m=n-k;
    mid1=(long double)(mid1*1.0/m+0.5);
    mid2=(long double)(mid2*1.0/m+0.5);

    ll x=mid1-mid2;
    //cout<<mid1<<' '<<mid2<<' '<<x<<endl;
    for(ll i=k;i<n;i++){
        ans+=abs(x+a[i].second-a[i].first);
    }
    cout<<ans<<endl;
    return 0;
}

# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 3296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 3292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 3316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 144 ms 3300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 89 ms 3192 KB Output is correct
2 Incorrect 106 ms 3344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 112 ms 3296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 3320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 3264 KB Output isn't correct
2 Halted 0 ms 0 KB -