#include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> h(N);
map<int, int> cnt;
for (int i = 0;i < N; ++i) {
cin >> h[i];
cnt[h[i]] += 1;
}
int MAX_H = 1e6 + 37;
vector<int> div_cnt(MAX_H);
for (auto [i, num] : cnt) {
if (i <= K) {
continue;
}
for (int j = 0;i * j < MAX_H; ++j) {
div_cnt[i * j] += num;
}
}
for (int i = 0;i < N; ++i) {
if (h[i] - K < 0) {
cout << 0 << ' ';
continue;
}
cout << (div_cnt[h[i] - K] - (K == 0)) << ' ';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4444 KB |
Output is correct |
2 |
Correct |
5 ms |
4416 KB |
Output is correct |
3 |
Correct |
34 ms |
5100 KB |
Output is correct |
4 |
Correct |
91 ms |
6552 KB |
Output is correct |
5 |
Correct |
69 ms |
9552 KB |
Output is correct |
6 |
Correct |
151 ms |
10576 KB |
Output is correct |
7 |
Correct |
60 ms |
9444 KB |
Output is correct |
8 |
Correct |
61 ms |
9552 KB |
Output is correct |
9 |
Correct |
155 ms |
10372 KB |
Output is correct |
10 |
Correct |
148 ms |
10324 KB |
Output is correct |