#CCBCHBAHAI0000096. Final Array Clinic - tìm và sửa 12 lỗi
Final Array Clinic - tìm và sửa 12 lỗi
Final Array Clinic - Diagnose 12 Array Errors
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
This clinic turns 12 common array bugs into 12 exact diagnostic results.
Given a static array of capacity and logical size , an integer , and insertion index (), compute:
- ; 2. ; 3. ; 4. ; 5. the sum; 6. the minimum; 7. the maximum; 8. the first index of or ; 9. the last index of or ; 10. the frequency of ; 11. whether ; and 12. the final array after inserting at only when capacity allows it.
If insertion is possible, shift the suffix right and set ; otherwise keep the array unchanged.
Input
The first line contains , , , and . The second line contains integers .
Output
Line 1 prints . Line 2 prints . Line 3 prints the final array .
Subtask
Subtask 1 (20 points): , .
Subtask 2 (30 points): , .
Subtask 3 (50 points): , .
Example
Input
7 5 2 4
4 1 4 9 2
Output
5 4 4 2 20 1 9 0 2 2 1
6
4 1 4 4 9 2
Explanation
The result follows directly from the mathematical definition above.