pair
user_7940789
c_cpp
a year ago
712 B
32
Indexable
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
int main() {
int t, n;
cin >> t;
while (t--) {
cin >> n;
vector<pair<int, int>> arr(n);
vector<int> ans(1005, 0);
REP(i, n) {
cin >> arr[i].first;
}
REP(i, n) {
cin >> arr[i].second;
}
sort(arr.begin(), arr.end());
int greaterCount = 0;
REP(i, n) {
greaterCount = arr[i].second;
REP(j, n) {
if (greaterCount == 0 && ans[j] == 0) {
ans[j] = arr[i].first;
break;
}
if (ans[j] == 0)
greaterCount--;
}
}
REP(i, n) {
cout << ans[i] << " ";
}
cout << endl;
}
}Editor is loading...
Leave a Comment