PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000167. Khôi phục thời tiết (Restore the Weather)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Khôi phục thời tiết (Restore the Weather)
Restore the Weather
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given forecast temperatures and the same days' actual temperatures in shuffled order . Reorder the multiset into so that for all . A valid rearrangement is guaranteed.
Input
The first line contains . The second contains forecast values ; the third contains actual values .
Output
Print values in day order, using exactly the input multiset and satisfying .
Subtasks
- Subtask 1 (20 points): ; ; ; bảo đảm tồn tại đáp án.
- Subtask 2 (30 points): ; ; ; bảo đảm tồn tại đáp án.
- Subtask 3 (50 points): ; ; ; bảo đảm tồn tại đáp án.
Examples
Input
5 2
1 3 5 3 9
2 5 11 2 4
Output
2 2 5 4 11
Explanation
Sort the forecast positions and the actual values, pair corresponding ranks, and restore original day indices. The resulting has absolute deviations , all at most , and retains the exact original multiset of actual temperatures.