Submission #100293

#TimeUsernameProblemLanguageResultExecution timeMemory
100293kraljlavova1Simfonija (COCI19_simfonija)C++11
44 / 110
49 ms5104 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; const int MAXN = 1e5 + 10, MAX = 2e6 + 10; int n, k, dif; int a[MAXN], b[MAXN]; int s[2 * MAX]; ll cur, sol = 4e18; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); cin >> n >> k; for(int i = 0;i < n; i++){ cin >> a[i]; } for(int i = 0;i < n; i++){ cin >> b[i]; } for(int i = 0;i < n; i++){ s[b[i] - a[i] + 1 + MAX] += 2; } for(int i = 0;i < n; i++){ int p = a[i] - MAX; cur += b[i] - p + 1; } dif = -n; for(int i = -MAX;i < MAX; i++){ sol = min(sol, cur); dif += s[i + MAX]; cur += dif; sol = min(sol, cur); } cout << sol << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...