Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <set>
  7. #include <map>
  8. #include <stack>
  9. #include <queue>
  10. #include <cstdlib>
  11. #include <cstdio>
  12. #include <string>
  13. #include <cstring>
  14. #include <cassert>
  15. #include <utility>
  16. #include <iomanip>
  17.  
  18. using namespace std;
  19.  
  20. const int MAXN = 1050;
  21.  
  22. int n;
  23. int a[MAXN], b[MAXN];
  24. int indA[MAXN], indB[MAXN];
  25. int ans[MAXN];
  26.  
  27. int main() {
  28. //assert(freopen("input.txt","r",stdin));
  29. //assert(freopen("output.txt","w",stdout));
  30.  
  31. scanf("%d", &n);
  32.  
  33. for (int i = 1; i <= n; i++) {
  34. scanf("%d", &a[i]);
  35. }
  36.  
  37. for (int i = 1; i <= n; i++) {
  38. scanf("%d", &b[i]);
  39. }
  40.  
  41. for (int i = 1; i <= n; i++) {
  42. indA[i] = i;
  43. indB[i] = i;
  44. }
  45.  
  46. for (int i = 1; i <= n; i++) {
  47. for (int j = 1; j < n; j++) {
  48. if (a[j] > a[j + 1]) {
  49. swap(a[j], a[j + 1]);
  50. swap(indA[j], indA[j + 1]);
  51. }
  52. }
  53. }
  54.  
  55. for (int i = 1; i <= n; i++) {
  56. for (int j = 1; j < n; j++) {
  57. if (b[j] < b[j + 1]) {
  58. swap(b[j], b[j + 1]);
  59. swap(indB[j], indB[j + 1]);
  60. }
  61. }
  62. }
  63.  
  64. for (int i = 1; i <= n; i++)
  65. ans[indA[i]] = indB[i];
  66.  
  67. for (int i = 1; i <= n; i++)
  68. printf("%d ", ans[i]);
  69.  
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement