Submission #676431

# Submission time Handle Problem Language Result Execution time Memory
676431 2022-12-30T22:00:24 Z Essa2006 Simfonija (COCI19_simfonija) C++14
0 / 110
26 ms 3668 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (int)(1000000007)
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k;
    cin>>n>>k;
    vector<int>A(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=0, a;i<n;i++){
        cin>>a;
        A[i]-=a;
    }
    sort(all(A));
    vector<int>Pre(n);
    Pre[0]=A[0];
    int ans=1e18;
    for(int i=1;i<n;i++)
        Pre[i]=Pre[i-1]+A[i];
    int md=(n-k)/2;
    for(int i=0, r=n-k-1;i<n;i++, r++){
        int ind=md+i, val=A[ind];
        int sum=(ind-i+1)*val-(Pre[ind]-(i?Pre[i-1]:0))+(r+1?Pre[r]:0)-Pre[ind]-val*(r-(ind+1)+1);
        ans=min(ans, sum);
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 3540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 3528 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 3540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 3668 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 3544 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 3540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 3544 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 3552 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 3528 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -