forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_207.cpp
More file actions
41 lines (37 loc) · 656 Bytes
/
_207.cpp
File metadata and controls
41 lines (37 loc) · 656 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
31
32
33
34
35
36
37
38
39
40
//ac
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;
class f {
public:
double e;
int idx;
bool operator < (const f &r) const {
return e > r.e;
}
};
int main() {
int n, m, y;
scanf("%d %d %d", &n, &m, &y);
vector<int> x(n), k(n);
vector<f> mm(n);
int num = 0;
for (int i = 0; i < n; ++i) {
scanf("%d", &x[i]);
k[i] = m * x[i] / y;
num += k[i];
mm[i].e = fabs(x[i] * 1.0 / y - k[i] * 1.0 / m);
mm[i].idx = i;
}
sort(mm.begin(), mm.end());
num = m - num;
for (int i = 0; i < num; ++i) {
k[mm[i].idx] += 1;
}
for (int i = 0; i < n; ++i) {
printf("%d ", k[i]);
}
return 0;
}