#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll LOGN = 20;
const ll MAXN = 1e6 + 5;
vector<ll> A, A2;
ll divCnt[MAXN], newCnt[MAXN];
map<ll,ll> mp;
int main() {
fast
ll N, K;
cin >> N >> K;
A = vector<ll>(N+1);
A2 = vector<ll>(N+1);
for (int i = 1; i <= N; i++) {
cin >> A[i];
mp[A[i]]++;
A2[i] = A[i];
}
sort(A2.begin(), A2.end());
for (int i = 1; i <= N; i++)
divCnt[A[i]]++;
for (int i = 1; i <= N; i++) {
if (A[i] == K)
continue;
for (int j = A[i]; j <= MAXN; j+=A[i]) {
newCnt[j] += divCnt[A[i]];
}
}
for (int i = 1; i <= N; i++) {
if (A[i] == K) {
int Q = upper_bound(A2.begin(), A2.end(), A[i]) - A2.begin();
cout << N - Q + 1 << " ";
} else if (A[i] < K)
cout << "0 ";
else {
ll ans = newCnt[A[i] - K];
cout << ans << " ";
}
}
cout << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
15448 KB |
Output isn't correct |
2 |
Incorrect |
12 ms |
15192 KB |
Output isn't correct |
3 |
Incorrect |
391 ms |
17356 KB |
Output isn't correct |
4 |
Incorrect |
866 ms |
21740 KB |
Output isn't correct |
5 |
Incorrect |
69 ms |
24188 KB |
Output isn't correct |
6 |
Incorrect |
170 ms |
27684 KB |
Output isn't correct |
7 |
Incorrect |
82 ms |
24144 KB |
Output isn't correct |
8 |
Incorrect |
73 ms |
24144 KB |
Output isn't correct |
9 |
Incorrect |
177 ms |
27216 KB |
Output isn't correct |
10 |
Incorrect |
173 ms |
27384 KB |
Output isn't correct |