-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_Restore_the_Weather.cpp
More file actions
51 lines (47 loc) · 1.26 KB
/
B_Restore_the_Weather.cpp
File metadata and controls
51 lines (47 loc) · 1.26 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
#include <iostream>
#include <algorithm>
#include <vector>
int main(int argc, char const *argv[])
{
unsigned short test;
std::cin >> test;
while (test--)
{
unsigned int daysNumber, maximumDiff;
std::cin >> daysNumber >> maximumDiff;
std::vector<std::pair<int, int>> a(daysNumber);
std::vector<int> b(daysNumber);
for (size_t i = 0; i < daysNumber; i++)
{
std::cin >> a[i].first;
a[i].second = i;
}
for (size_t i = 0; i < daysNumber; i++)
{
std::cin >> b[i];
}
std::sort(a.begin(), a.end());
std::sort(b.begin(), b.end(), std::less<int>());
std::vector<int> solution(daysNumber);
for (size_t i = 0; i < daysNumber; i++)
{
solution[a[i].second] = b[i];
}
for (auto &&i : a)
{
std::cout << i.first << " " << i.second << " ";
}
std::cout << std::endl;
for (auto &&i : b)
{
std::cout << i << " ";
}
std::cout << std::endl;
for (size_t i = 0; i < daysNumber; i++)
{
std::cout << solution[i] << std::endl;
}
std::cout << "\n";
}
return 0;
}