Submission #256655

# Submission time Handle Problem Language Result Execution time Memory
256655 2020-08-03T05:14:12 Z MrRobot_28 Spiderman (COCI20_spiderman) C++17
70 / 70
97 ms 12152 KB
#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 time Memory Grader output
1 Correct 23 ms 8192 KB Output is correct
2 Correct 23 ms 8192 KB Output is correct
3 Correct 43 ms 9464 KB Output is correct
4 Correct 86 ms 12152 KB Output is correct
5 Correct 44 ms 9464 KB Output is correct
6 Correct 97 ms 12152 KB Output is correct
7 Correct 45 ms 9464 KB Output is correct
8 Correct 46 ms 9392 KB Output is correct
9 Correct 90 ms 12024 KB Output is correct
10 Correct 91 ms 12028 KB Output is correct