#CCBCHBAHAI0000096. Final Array Clinic - tìm và sửa 12 lỗi

    ID: 1014 Loại: Thông thường 2000ms 256MiB Tried: 0 Đã chấp nhận: 0 Độ khó: 1 Đăng bởi: Nhãn>Programming language basicsStatic arraysIteration techniquesImplementation techniquesWorking with numbersInteger arithmetic

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 CC and logical size nn, an integer xx, and insertion index pp (0≤p≤n0\le p\le n), compute:

  1. D1=nD_1=n; 2. D2=n−1D_2=n-1; 3. D3=a0D_3=a_0; 4. D4=an−1D_4=a_{n-1}; 5. the sum; 6. the minimum; 7. the maximum; 8. the first index of xx or −1-1; 9. the last index of xx or −1-1; 10. the frequency of xx; 11. whether n<Cn<C; and 12. the final array after inserting xx at pp only when capacity allows it.

If insertion is possible, shift the suffix right and set bp=xb_p=x; otherwise keep the array unchanged.

Input

The first line contains CC, nn, pp, and xx. The second line contains nn integers aia_i.

Output

Line 1 prints D1,…,D11D_1,\ldots,D_{11}. Line 2 prints mm. Line 3 prints the final array bb.

Subtask

Subtask 1 (20 points): 1≤n≤C≤101\le n\le C\le10, ∣ai∣,∣x∣≤103|a_i|,|x|\le10^3.

Subtask 2 (30 points): 1≤n≤C≤50001\le n\le C\le5000, ∣ai∣,∣x∣≤106|a_i|,|x|\le10^6.

Subtask 3 (50 points): 1≤n≤C≤2⋅1051\le n\le C\le2\cdot10^5, ∣ai∣,∣x∣≤109|a_i|,|x|\le10^9.

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.