Submission #256655

#TimeUsernameProblemLanguageResultExecution timeMemory
256655MrRobot_28Spiderman (COCI20_spiderman)C++17
70 / 70
97 ms12152 KiB
#include<bits/stdc++.h>
 
using namespace std;

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector <int> cnt(1e6 + 1, 0), cnt1(1e6 + 1, 0);
	vector <int> h(n);
	int a = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> h[i];
		if(h[i] > k)
		{
			a++;
			cnt1[h[i]]++;
		}
	}
	for(int j = 1; j <= 1e6; j++)
	{
		int k = j;
		while(k <= 1e6)
		{
			cnt[k] += cnt1[j];
			k += j;
		}
	}
	for(int i = 0; i < n; i++)
	{
		if(h[i] < k)
		{
			cout << 0 << " ";
		}
		else if(h[i] == k)
		{
			cout << a << " ";
		}
		else if(k == 0)
		{
			cout << cnt[h[i]] - 1 << " " ;
		}
		else
		{
			cout << cnt[h[i] - k] << " ";
		}
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...