#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
void solve(){
int n,k;cin >> n >> k;
int arr[n],cnt[N],bigger[N];
memset(cnt , 0 , sizeof(cnt));
memset(bigger , 0 , sizeof(bigger));
for(int i = 0;i<n;i++){
cin >> arr[i];
cnt[arr[i]]++;
bigger[arr[i]]++;
}
for(int i = N-1;i>=0;i--){
bigger[i] += bigger[i+1];
}
for(int i = 0;i<n;i++){
int ans = 0;
//bigger
if(arr[i] == k)ans = bigger[arr[i]+1];
//smaller
int temp = arr[i] - k;
for(int i = 1;i*i<=temp;i++){
if(temp % i == 0){
if(i > k)ans += cnt[i];
if((temp/i) > k)ans += cnt[temp / i];
}
}
cout << ans << " ";
}
cout << endl;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
8280 KB |
Output isn't correct |
2 |
Incorrect |
12 ms |
8280 KB |
Output isn't correct |
3 |
Incorrect |
269 ms |
9220 KB |
Output isn't correct |
4 |
Incorrect |
779 ms |
10324 KB |
Output isn't correct |
5 |
Incorrect |
309 ms |
8784 KB |
Output isn't correct |
6 |
Incorrect |
893 ms |
10576 KB |
Output isn't correct |
7 |
Incorrect |
353 ms |
8784 KB |
Output isn't correct |
8 |
Incorrect |
352 ms |
8816 KB |
Output isn't correct |
9 |
Incorrect |
1029 ms |
10080 KB |
Output isn't correct |
10 |
Incorrect |
1022 ms |
10108 KB |
Output isn't correct |