#include #include #include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int32_t N, i, K; cin >> N >> K; int32_t* data = new int32_t[N * 3]; for (i = 0; i != N * 3; ++i) cin >> data[i]; int64_t ans = 0; for (i = 0; i != N; ++i) ans += data[i] + data[N * 2 + i], data[N + i] -= data[N * 2 + i]; sort(data + N, data + N * 2, greater()); for (i = 0; i != K; ++i) ans += data[N + i]; cout << ans << '\n'; delete[] data; return 0; }