#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const long double eps = 1e-12;
const int N = 2e6 + 9;
long long ans[N];
pair<pair<int, int>, int> a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first.first;
    a[i].second = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i].first.second;
    a[i].first.second *= -1;
  }
  sort(a, a + n);
  multiset<int> ss;
  for (int i = 0; i < n; i++) {
    42;
    int j = 0;
    auto it = ss.begin();
    ans[a[i].second] = a[i].first.second;
    while (j < m && it != ss.end()) {
      ans[a[i].second] += (*it);
      it++;
      j++;
    }
    ss.insert(a[i].first.second);
  }
  for (int i = 0; i < n; i++) cout << -ans[i] << " ";
  cout << endl;
  return 0;
}
