#include <bits/stdc++.h>
using namespace std;
ostream& operator<<(ostream& os, const pair<int, int>& pai) {
  os << pai.first << ' ' << pai.second;
  return os;
}
istream& operator>>(istream& is, pair<int, int>& pai) {
  is >> pai.first >> pai.second;
  return is;
}
int n, k;
long long result[100001];
pair<pair<int, int>, int> arr[100001];
multiset<int> s;
int main() {
  ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first.first;
    arr[i].second = i;
  }
  for (int i = 0; i < n; i++) cin >> arr[i].first.second;
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) {
    for (int e : s) result[arr[i].second] += e;
    result[arr[i].second] += arr[i].first.second;
    if (s.size() < k)
      s.insert(arr[i].first.second);
    else {
      if (s.lower_bound(arr[i].first.second) != s.begin()) {
        s.erase(s.begin());
        s.insert(arr[i].first.second);
      }
    }
  }
  for (int i = 0; i < n; i++) cout << result[i] << ' ';
  cout << '\n';
  return 0;
}
