# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334964 | 2020-12-10T13:27:47 Z | ronnith | Simfonija (COCI19_simfonija) | C++14 | 52 ms | 3456 KB |
#include <bits/stdc++.h> #define trav(a, b) for(auto a : b) #define mk make_pair #define f first #define s second #define vi vector<int> #define pb push_back typedef long long ll; using namespace std; void re(vector<ll*> arr){ trav(e, arr)scanf("%lld", e); } ll n, k; ll a[100000], b[100000]; ll check(ll x){ ll ans = 0; for(int i = 0;i < n;i ++){ ans += abs(a[i] + x - b[i]); } return ans; } int main(){ // ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); re({&n,&k}); for(int i = 0;i < n;i ++){ re({&a[i]}); } for(int i = 0;i < n;i ++){ re({&b[i]}); } ll hi = 1e13; ll lo = -1e13; ll ans = LONG_LONG_MAX; while(hi >= lo){ ll g1 = lo + (hi - lo) / 2; ll g2 = g1 + 1; ll a1 = check(g1), a2 = check(g2); if(a1 == a2){ ans = a1; break; } else if(a1 < a2){ ans = min(ans, a1); hi = g1 - 1; } else if(a1 > a2){ ans = min(ans, a2); lo = g1 + 1; } } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 3308 KB | Output is correct |
2 | Correct | 44 ms | 3308 KB | Output is correct |
3 | Correct | 43 ms | 3436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 3308 KB | Output is correct |
2 | Correct | 41 ms | 3308 KB | Output is correct |
3 | Correct | 42 ms | 3308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 3308 KB | Output is correct |
2 | Correct | 47 ms | 3308 KB | Output is correct |
3 | Correct | 45 ms | 3456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 38 ms | 2668 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 52 ms | 3364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 41 ms | 3308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 46 ms | 3308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 44 ms | 3308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 41 ms | 3308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |