#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
int a[300001], h[300001], ans[1000001], cnt[1000001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
set<int> s;
FOR(i, 0, n) {
cin >> h[i];
cnt[h[i]]++;
s.insert(h[i]);
}
int m = 0;
for (int i : s) a[m++] = i;
FOR(i, 0, m) {
if (a[i] <= k) continue;
for (int j = k; j <= a[m - 1]; j += a[i]) ans[j] += cnt[a[i]] - (a[i] == j);
}
FOR(i, 0, n) cout << ans[h[i]] << ' ';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
6680 KB |
Output is correct |
2 |
Correct |
13 ms |
5752 KB |
Output is correct |
3 |
Correct |
43 ms |
8056 KB |
Output is correct |
4 |
Correct |
98 ms |
10616 KB |
Output is correct |
5 |
Correct |
99 ms |
14588 KB |
Output is correct |
6 |
Correct |
203 ms |
16888 KB |
Output is correct |
7 |
Correct |
97 ms |
14584 KB |
Output is correct |
8 |
Correct |
94 ms |
14480 KB |
Output is correct |
9 |
Correct |
186 ms |
16632 KB |
Output is correct |
10 |
Correct |
192 ms |
16632 KB |
Output is correct |