Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <set>
- #include <algorithm>
- #define L long long
- using namespace std;
- L tt, n, a[1002], b[1002], t[1002];
- int main(){
- cin >> tt;
- for (int i = 0; i < tt; i++){
- cin >> n;
- fill(t, t + 1001, -999999);
- map<L, L> myMap;
- for (int j = 0; j < n; j++)
- cin >> a[j];
- for (int j = 0; j < n; j++)
- cin >> b[j];
- for (int j = 0; j < n; j++)
- myMap.insert(pair<L, L>(a[j], b[j]));
- for (auto it = myMap.begin(); it != myMap.end(); ++it){
- if(t[(*it).second] == -999999)
- t[(*it).second] = (*it).first;
- else{
- int ind = (*it).second;
- while(t[ind] != -999999)
- ind++;
- ind += (*it).second;
- t[ind] = (*it).first;
- }
- }
- for (int i = 0; i < n; i++)
- cout << t[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement