Submission #101274

# Submission time Handle Problem Language Result Execution time Memory
101274 2019-03-18T07:25:56 Z mayhoubsaleh Simfonija (COCI19_simfonija) C++14
0 / 110
114 ms 2564 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

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

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


//ofstream fout("planting.out");
//ifstream fin("planting.in");
# 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 91 ms 2540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 2560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 2504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 60 ms 1784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 2512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 94 ms 2436 KB Output is correct
2 Incorrect 91 ms 2460 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 2564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 2424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 114 ms 2552 KB Output isn't correct
2 Halted 0 ms 0 KB -