답안 #225117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225117 2020-04-19T09:36:10 Z kartel Simfonija (COCI19_simfonija) C++14
44 / 110
57 ms 4464 KB
#include <bits/stdc++.h>
#define in(x) freopen(x,"r",stdin)
#define out(x) freopen(x,"w",stdout)
#define F first
#define S second
#define pb push_back
#define M ll(998244353)
#define inf ll(2e9+7)
#define N ll(200500)
#define sz(x) x.size()
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
#define el '\n'
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> os;

ll a[N], b[N], i, n, k, ans = 1e18, kl, sm, sum, c[N], pr[N];
vector <ll> ve;

int main()
{
//    in("input.txt");
//    out("output.txt");

    ios_base::sync_with_stdio(false);
    iostream::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    for (i = 1; i <= n; i++) cin >> a[i];
    for (i = 1; i <= n; i++)
    {
        cin >> b[i];
        c[i] = b[i] - a[i];
    }

    sort(c + 1, c + 1 + n);

    for (i = 1; i <= n; i++) a[i] += c[n / 2];

    for (i = 1; i <= n; i++) ve.pb(b[i] - a[i]);

    sort(ve.begin(), ve.end());

    pr[0] = abs(ve[0]);

    for (i = 1; i < n; i++) pr[i] = pr[i - 1] + abs(ve[i]);

    for (i = 0; i <= k; i++)
    {
        ans = min(ans, pr[i + n - k - 1] - (((i - 1) >= 0) ? pr[i - 1] : 0));
    }

    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 4464 KB Output is correct
2 Correct 42 ms 4464 KB Output is correct
3 Correct 37 ms 4336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 4336 KB Output is correct
2 Correct 43 ms 4336 KB Output is correct
3 Correct 40 ms 4336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 4464 KB Output is correct
2 Correct 43 ms 4464 KB Output is correct
3 Correct 38 ms 4336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 4420 KB Output is correct
2 Correct 38 ms 4336 KB Output is correct
3 Incorrect 40 ms 4336 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 4336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 4336 KB Output is correct
2 Incorrect 40 ms 4336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 57 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 4336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 4336 KB Output isn't correct
2 Halted 0 ms 0 KB -