Submission #158908

# Submission time Handle Problem Language Result Execution time Memory
158908 2019-10-19T12:19:20 Z dolphingarlic Simfonija (COCI19_simfonija) C++14
44 / 110
54 ms 2040 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (ll i = x; i < y; i++)
typedef long long ll;
using namespace std;

ll d[100000], e[100000];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    FOR(i, 0, n) cin >> d[i];
    FOR(i, 0, n) {
        ll x;
        cin >> x;
        d[i] -= x;
    }
    sort(d, d + n);

    FOR(i, 0, n) e[i] = d[i];
    ll x = d[n / 2], y = d[(n - 1) / 2];
    FOR(i, 0, n) {
        d[i] -= x, e[i] -= y;
        d[i] = abs(d[i]), e[i] = abs(e[i]);
    }
    sort(d, d + n);
    sort(e, e + n);

    ll da = 0, ea = 0;
    FOR(i, 0, n - k) da += d[i], ea += e[i];
    cout << min(da, ea);
    return 0;
}
# 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 44 ms 1884 KB Output is correct
2 Correct 40 ms 1884 KB Output is correct
3 Correct 36 ms 1972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 1840 KB Output is correct
2 Correct 39 ms 1892 KB Output is correct
3 Correct 35 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1912 KB Output is correct
2 Correct 38 ms 1916 KB Output is correct
3 Correct 34 ms 2040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1912 KB Output is correct
2 Correct 33 ms 1968 KB Output is correct
3 Incorrect 35 ms 1912 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 1912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1972 KB Output is correct
2 Incorrect 35 ms 1912 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 2040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 2040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 1912 KB Output isn't correct
2 Halted 0 ms 0 KB -