#include <bits/stdc++.h>
using namespace std;
long long n, k;
string s;
int MOD = 1e9 + 7;
const int INF = 1e9;
const long long INF64 = 1e18;
const double PI = 3.141592653589793238463;
long long ar[1000004], vis[1000004], pre[1000004];
vector<long long> le, rt;
set<long long> myset;
pair<long long, pair<long long, long long> > segs[1000004];
map<long long, long long> mymap;
long long c = 1;
string st[1000004], st2[1000004];
vector<long long> arr[1000004];
struct Seg {
  int i, p, c;
} seg[1000004];
int comp(Seg a, Seg b) { return a.p < b.p; }
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cin >> n >> k;
  for (int i = 0; i < int(n); i++) {
    cin >> seg[i].p;
    seg[i].i = i;
  }
  for (int i = 0; i < int(n); i++) cin >> seg[i].c;
  sort(seg, seg + n, comp);
  vector<int> coin;
  for (int i = 0; i < int(n); i++) {
    ar[seg[i].i] = seg[i].c;
    if (i) {
      if (i <= k) {
        coin.push_back(seg[i - 1].c);
      } else if (coin.size()) {
        sort(coin.begin(), coin.end());
        if (coin[0] < seg[i - 1].c) coin[0] = seg[i - 1].c;
      }
    }
    for (int j = 0; j < coin.size(); j++) ar[seg[i].i] += coin[j];
  }
  for (int i = 0; i < int(n); i++) cout << ar[i] << ' ';
  return cout << endl, 0;
}
