-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQUE.cpp
More file actions
46 lines (44 loc) · 673 Bytes
/
QUE.cpp
File metadata and controls
46 lines (44 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
int ans[10010];
int main()
{
vector< pair<int,int> > v;
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
v.resize(n);
memset(ans,0,sizeof(ans));
for (int i = 0; i < n; ++i)
{
scanf("%d",&v[i].first);
}
for (int i = 0; i < n; ++i)
{
scanf("%d",&v[i].second);
}
sort(v.begin(),v.end());
for (int i = 0; i < n; ++i)
{
int g = v[i].second;
for (int j = 0; j < n; ++j)
{
if(g == 0 && ans[j] == 0)
{
ans[j] = v[i].first;
break;
}
if(ans[j] ==0 )
g--;
}
}
for (int i = 0; i < n; ++i)
{
printf("%d ", ans[i]);
}
printf("\n");
}
}