#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]]++;
if(arr[i]>maxi) maxi=arr[i];
}
for(auto p:num){
for(auto q:num){
if(p.st%q.st==k) ans[p.st]+=q.nd;
}
}
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.txt","r",stdin);
freopen("out","w",stdout);
#endif
ll t=1;
//cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
600 KB |
Output is correct |
2 |
Correct |
6 ms |
600 KB |
Output is correct |
3 |
Correct |
44 ms |
1696 KB |
Output is correct |
4 |
Correct |
86 ms |
3900 KB |
Output is correct |
5 |
Execution timed out |
2049 ms |
7536 KB |
Time limit exceeded |
6 |
Execution timed out |
2050 ms |
8416 KB |
Time limit exceeded |
7 |
Execution timed out |
2044 ms |
7512 KB |
Time limit exceeded |
8 |
Execution timed out |
2050 ms |
7760 KB |
Time limit exceeded |
9 |
Execution timed out |
2040 ms |
8724 KB |
Time limit exceeded |
10 |
Execution timed out |
2040 ms |
8700 KB |
Time limit exceeded |