-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy pathb.cc
34 lines (32 loc) · 736 Bytes
/
b.cc
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
31
32
33
34
// https://atcoder.jp/contests/arc118/tasks/arc118_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
int main() {
cin.tie(0), ios::sync_with_stdio(0);
ll k, n, m, sum = 0;
cin >> k >> n >> m;
vi a(k);
vector<pair<ll, ll>> b(k);
for (int i = 0; i < k; i++) {
cin >> a[i];
ll mod = (a[i] * m) % n;
sum += mod;
b[i] = {mod, i};
}
sort(b.rbegin(), b.rend());
for (int i = 0; i < k; i++) {
if (!sum) break;
b[i].first -= n;
sum -= n;
}
assert(!sum);
vi ans(k);
for (int i = 0; i < k; i++) {
int j = b[i].second;
ans[j] = a[j] * m - b[i].first;
ans[j] /= n;
}
for (int i = 0; i < k; i++) cout << ans[i] << " \n"[i == k - 1];
}