# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147412 | 2019-08-29T13:21:59 Z | ipaljak | Simfonija (COCI19_simfonija) | C++14 | 44 ms | 3316 KB |
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " " << x << endl #define FOR(i, a, b) for (int i = (a); i < int(b); ++i) #define REP(i, n) FOR(i, 0, n) #define _ << " " << typedef long long llint; const int MOD = 1e9 + 7; const int MAXN = 1e5 + 10; int n, k; int a[MAXN], b[MAXN]; int main(void) { scanf("%d%d", &n, &k); for (int i = 0; i < n; ++i) scanf("%d", &a[i]); for (int i = 0; i < n; ++i) scanf("%d", &b[i]); vector<int> v; for (int i = 0; i < n; ++i) v.emplace_back(a[i] - b[i]); sort(v.begin(), v.end()); int med = v[n / 2 - (n % 2 == 0)]; int lo = 0, hi = n - 1; for (int i = 0; i < k; ++i) { if (abs(v[lo] - med) > abs(v[hi] - med)) ++lo; else --hi; } //TRACE(lo _ hi _ med); //for (int x : v) printf("%d ", x); //printf("\n"); llint sol = 0; for (int i = lo; i <= hi; ++i) sol += (llint) abs(v[i] - med); printf("%lld\n", sol); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 3164 KB | Output is correct |
2 | Correct | 40 ms | 3188 KB | Output is correct |
3 | Correct | 39 ms | 3248 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 3188 KB | Output is correct |
2 | Correct | 40 ms | 3200 KB | Output is correct |
3 | Correct | 39 ms | 3188 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 3188 KB | Output is correct |
2 | Correct | 40 ms | 3196 KB | Output is correct |
3 | Correct | 38 ms | 3188 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 2552 KB | Output is correct |
2 | Correct | 37 ms | 3132 KB | Output is correct |
3 | Incorrect | 39 ms | 3316 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 43 ms | 3188 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 3188 KB | Output is correct |
2 | Incorrect | 39 ms | 3188 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 44 ms | 3288 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 42 ms | 3144 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 38 ms | 3160 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |