Submission #318853

# Submission time Handle Problem Language Result Execution time Memory
318853 2020-11-03T10:24:57 Z neki Simfonija (COCI19_simfonija) C++14
0 / 110
83 ms 2748 KB
#include <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 100100
#define pa pair<ll, ll>
#define ld long double 
ll a[mn], b[mn], srt[mn];
ll mm=10;
int main(){
    ll n, k;cin>> n >> k;
    loop(i, 0, n) cin >> a[i];
    loop(i, 0, n) cin >> b[i];
    loop(i, 0, n) srt[i+1]=b[i]-a[i];
    sort(srt+1, srt+n+1);
    ll j=0, ans=llmax, l=0, r=k, cur=n-r;
    loop(i, 1, n-k+1) cur+=srt[i]+mm;
    loop(i, -mm, mm){
        while(j<n and srt[j+1]<i)j++;
        cur-=n-j-j+l-r;
        while(l+1<j and r>0 and i-srt[l+1]>=srt[n+1-r]-i) cur-=srt[n+1-r]+srt[l+1]-2 * i,l++, r--;
        
        cout << i << " "<<cur <<" "<<l << " "<<r<<endl;
        ans=min(ans, cur);
    }
    cout << ans <<endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 2660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 2748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 2660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 2660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 2660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 2620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 2588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 2720 KB Output isn't correct
2 Halted 0 ms 0 KB -