-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path36. Pair Programming (Code Forces- Round 731 - Div. 3).cpp
More file actions
62 lines (55 loc) · 1.4 KB
/
36. Pair Programming (Code Forces- Round 731 - Div. 3).cpp
File metadata and controls
62 lines (55 loc) · 1.4 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <bits/stdc++.h>
using namespace std;
void solve(){
int k,n,m;
cin>>k>>n>>m;
vector<int>a(n),b(m);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<m;i++) cin>>b[i];
int x=0,y=0;
vector<int>ans;
while(x<n || y<m){
if(x<n && y<m){
if(a[x]==0) ans.push_back(0), x++, k++;
else if(b[y]==0) ans.push_back(0), y++, k++;
else{
if(a[x]<b[y] && a[x]<=k) ans.push_back(a[x]), x++;
else if(a[x]>=b[y] && b[y]<=k) ans.push_back(b[y]), y++;
else{
cout<<-1<<"\n";
return;
}
}
}
else if(x<n){
if(a[x]==0) ans.push_back(0), x++, k++;
else{
if(a[x]<=k) ans.push_back(a[x]), x++;
else{
cout<<-1<<"\n";
return;
}
}
}
else if(y<m){
if(b[y]==0) ans.push_back(0), y++, k++;
else{
if(b[y]<=k) ans.push_back(b[y]), y++;
else{
cout<<-1<<"\n";
return;
}
}
}
}
for(auto x : ans) cout<<x<<" ";
cout<<"\n";
}
int main(){
int t;
cin>>t;
for(int i=1;i<=t;i++){
solve();
}
return 0;
}