#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
using namespace std;
void solve(){
int n, k; cin >> n >> k;
int arr[n+1];
map<int, int> num;
map<int, int> ans;
int maxi=0;
for(int i=1; i<=n; i++){
cin >> arr[i];
num[arr[i]]++;
maxi=max(maxi, arr[i]);
}
for(auto p:num){
if(k%p.st==0) continue;
for(int i=p.st+k; i<=maxi; i+=p.st){
ans[i]+=p.nd;
}
}
if(num[k]>0){
for(int i=k+1; i<=maxi; i++) ans[k]+=num[i];
}
for(int i=1; i<=n; i++) cout << ans[arr[i]] << " ";
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
ll t=1;
//cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1679 ms |
110840 KB |
Output isn't correct |
2 |
Incorrect |
1642 ms |
116748 KB |
Output isn't correct |
3 |
Execution timed out |
2037 ms |
57712 KB |
Time limit exceeded |
4 |
Incorrect |
1898 ms |
116012 KB |
Output isn't correct |
5 |
Incorrect |
76 ms |
13904 KB |
Output isn't correct |
6 |
Incorrect |
157 ms |
14632 KB |
Output isn't correct |
7 |
Execution timed out |
2050 ms |
57212 KB |
Time limit exceeded |
8 |
Execution timed out |
2045 ms |
57484 KB |
Time limit exceeded |
9 |
Execution timed out |
2025 ms |
62008 KB |
Time limit exceeded |
10 |
Execution timed out |
2061 ms |
63976 KB |
Time limit exceeded |