forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathG.cpp
More file actions
30 lines (25 loc) · 620 Bytes
/
G.cpp
File metadata and controls
30 lines (25 loc) · 620 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n, M, Y, x[1010], roundUp = 0;
pair <int,int> a[1010];
cin >> n >> M >> Y;
for (int i = 0; i < n; i++)
{
cin >> x[i];
a[i] = {x[i] * M % Y, i};
roundUp += a[i].first;
x[i] = x[i] * M / Y;
}
assert(roundUp % Y == 0);
roundUp /= Y;
sort(a, a + n);
for (int i = 1; i <= roundUp; i++)
x[a[n - i].second]++;
for (int i = 0; i < n; i++)
cout << x[i] << (i == n - 1 ? '\n' : ' ');
}