#include <bits/stdc++.h>
using namespace std;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const long long int Inf = 1LL << 62;
long long int ans[Max];
struct Node {
  int f, s, id;
} ar[Max];
bool cmp(Node a, Node b) { return a.f < b.f; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  multiset<long long int> st;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i].f;
    ar[i].id = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> ar[i].s;
  }
  sort(ar + 1, ar + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    long long int cost = 0;
    for (long long int x : st) {
      if (cnt == k) break;
      cost += -x;
      cnt++;
    }
    st.insert(-ar[i].s);
    ans[ar[i].id] = ar[i].s + cost;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
