#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  multiset<long long, greater<long long> > s;
  std::vector<pair<pair<long long, long long>, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first.first;
  }
  for (int j = 0; j < n; j++) {
    cin >> a[j].first.second;
    a[j].second = j;
  }
  vector<long long> an(n);
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    auto it = s.begin();
    long long ans = 0;
    for (int i = 0; i < k && it != s.end(); i++, it++) ans += *it;
    an[a[i].second] = ans + a[i].first.second;
    s.insert(a[i].first.second);
  }
  for (auto it : an) cout << it << " ";
  cout << endl;
  return 0;
}
