1. Concise Problem Statement  
Given N robbers, they agreed that robber i should receive Xi/Y of the loot. In reality they have M indivisible coins (M may not be divisible by Y). Assign each robber an integer Ki (sum of all Ki = M) to minimize the total unfairness  
   unfairness = ∑ |Xi/Y – Ki/M|.  
Output the Ki that achieve the minimum total unfairness.

2. Detailed Editorial  

Problem restatement and transformation  
- Ideal (real-valued) share for robber i is  
     a_i* = (Xi / Y)·M = Xi·M / Y.  
- We must choose integer Ki ≥ 0 with ∑Ki = M to approximate a_i*.  
- The contribution to unfairness from i is  
     |Xi/Y – Ki/M| = (1/M)·|a_i* – Ki|.  
- Minimizing ∑|Xi/Y – Ki/M| is equivalent to minimizing ∑|a_i* – Ki|.

Key observation:  
- For each i, the best integer Ki is either floor(a_i*) or ceil(a_i*).  
- Let f_i = ⌊a_i*⌋, c_i = ⌈a_i*⌉ = f_i or f_i+1.  
- If we choose Ki = f_i, the error is ε_i(floor) = a_i* – f_i = frac_i.  
  If we choose Ki = c_i, the error is ε_i(ceil) = c_i – a_i* = 1 – frac_i (unless frac_i=0).  
- The difference Δ_i in total error between picking ceil vs floor is  
     Δ_i = ε_i(ceil) – ε_i(floor)  
         = (1 – frac_i) – frac_i  
         = 1 – 2·frac_i.  
- A smaller Δ_i means that ceil gives a bigger reduction in error compared to floor; equivalently, larger frac_i favors choosing the ceil.

Global constraint:  
- Let S = ∑ f_i.  Since ∑ a_i* = M exactly, we have S ≤ M and ∑ c_i ≥ M.  
- We need exactly M coins, so we must “promote” exactly B = M – S of the indices from floor to ceil.  

Algorithm  
1. Compute for each i:  
   a_i* = Xi·M / Y (as double),  
   f_i = ⌊a_i*⌋,  frac_i = a_i* – f_i.  
2. Compute S = ∑ f_i, let B = M – S.  
3. Sort indices i in descending order of frac_i (or equivalently ascending order of Δ_i = 1–2·frac_i).  
4. For the top B indices, set Ki = f_i + 1; for the rest, Ki = f_i.  
5. Output the array K.  

Complexity  
- O(N) to compute floors and fractions, O(N log N) to sort, O(N) to build the answer. Works for N up to 1000.

3. Provided C++ Solution with Detailed Comments  

```cpp
#include <bits/stdc++.h>
using namespace std;

// Overload << to print a pair as "first second"
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

// Overload >> to read a pair
template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

// Overload >> to read a vector sequentially
template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for (auto& x: a) {
        in >> x;
    }
    return in;
}

// Overload << to print a vector elements separated by spaces
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for (auto x: a) {
        out << x << ' ';
    }
    return out;
}

int n, m, y;       // n = number of robbers, m = total coins, y = denominator
vector<int> x;     // x[i] are the Xi values

void read() {
    // Read n, m, y
    cin >> n >> m >> y;
    // Resize and read Xi values
    x.resize(n);
    cin >> x;
}

void solve() {
    // We will compute two arrays:
    // a_floor[i] = floor(a_i*), a_ceil[i] = ceil(a_i*)
    // delta[i] = difference in error between ceil and floor = 1 - 2*frac_i
    vector<int> a_floor(n), a_ceil(n);
    vector<double> delta(n);

    // sum_floor = sum of all floor values
    int sum_floor = 0;

    for (int i = 0; i < n; i++) {
        // Ideal real share times M: Xi * m / y
        // floor and ceil of the real share
        a_floor[i] = (x[i] * m) / y;              // integer division = floor
        a_ceil[i]  = (x[i] * m + y - 1) / y;      // equivalent to ceil

        sum_floor += a_floor[i];

        // If floor == ceil, fraction is zero, no choice
        if (a_floor[i] == a_ceil[i]) {
            delta[i] = 1e9;  // put a large penalty, will never choose ceil
            continue;
        }

        // Compute the exact real value as double
        double a_exact = double(x[i]) * m / y;
        // frac_i = a_exact - floor, so delta = (1 - frac_i) - frac_i = 1 - 2*frac_i
        double frac = a_exact - a_floor[i];
        delta[i] = 1.0 - 2.0 * frac;
    }

    // We need to increase exactly 'buffer' floors to ceilings
    int buffer = m - sum_floor;  // how many +1 assignments we must do

    // Create a permutation of indices [0..n-1]
    vector<int> perm(n);
    iota(perm.begin(), perm.end(), 0);

    // Sort indices by delta ascending (i.e. frac descending)
    sort(perm.begin(), perm.end(), [&](int i, int j) {
        return delta[i] < delta[j];
    });

    // Sanity: buffer cannot exceed n
    assert(buffer <= n);

    // Promote the first 'buffer' elements in sorted order to ceiling
    for (int k = 0; k < buffer; k++) {
        int i = perm[k];
        a_floor[i] = a_ceil[i];
    }

    // Output the final Ki (stored in a_floor)
    cout << a_floor << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // Single test case
    read();
    solve();
    return 0;
}
```

4. Python Solution with Detailed Comments  

```python
import sys

def main():
    data = sys.stdin.read().split()
    it = iter(data)
    n = int(next(it))
    m = int(next(it))
    y = int(next(it))
    x = [int(next(it)) for _ in range(n)]

    # Compute floor, fractional parts, and prepare for sorting
    floors = [0]*n
    fracs  = [0.0]*n
    sum_floor = 0

    for i in range(n):
        # ideal real share times M
        exact = x[i]*m / y
        f = int(exact)           # floor
        sum_floor += f
        floors[i] = f
        fracs[i] = exact - f     # fractional part in [0,1)

    # buffer = how many 1-coin increments we need
    buffer = m - sum_floor

    # Pair each index with its fractional part
    # We want the largest fractional parts first
    idx = list(range(n))
    idx.sort(key=lambda i: fracs[i], reverse=True)

    # Promote the top 'buffer' floors to floors+1
    for k in range(buffer):
        i = idx[k]
        floors[i] += 1

    # Output the result
    print(*floors)

if __name__ == "__main__":
    main()
```

5. Compressed Editorial  
- Compute ideal real shares a_i* = Xi·M/Y.  
- Let f_i = ⌊a_i*⌋, sum S = ∑f_i. Buffer = M–S.  
- Fraction frac_i = a_i*–f_i.  
- Increase to ⌈a_i*⌉ exactly Buffer robbers with largest frac_i.