Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <set>
  4. #include <algorithm>
  5. #define L long long
  6.  
  7. using namespace std;
  8.  
  9. L tt, n, a[1002], b[1002], t[1002];
  10.  
  11. int main(){
  12.     cin >> tt;
  13.     for (int i = 0; i < tt; i++){
  14.         cin >> n;
  15.         fill(t, t + 1001, -999999);
  16.         map<L, L> myMap;
  17.         for (int j = 0; j < n; j++)
  18.             cin >> a[j];
  19.         for (int j = 0; j < n; j++)
  20.             cin >> b[j];
  21.         for (int j = 0; j < n; j++)
  22.             myMap.insert(pair<L, L>(a[j], b[j]));
  23.         for (auto it = myMap.begin(); it != myMap.end(); ++it){
  24.             if(t[(*it).second] == -999999)
  25.                 t[(*it).second] = (*it).first;
  26.             else{
  27.                 int ind = (*it).second;
  28.                 while(t[ind] != -999999)
  29.                     ind++;
  30.                 ind += (*it).second;
  31.                 t[ind] = (*it).first;
  32.             }
  33.         }
  34.         for (int i = 0; i < n; i++)
  35.             cout << t[i] << " ";
  36.     }  
  37.            
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement