Submission #671168

# Submission time Handle Problem Language Result Execution time Memory
671168 2022-12-12T09:14:51 Z Nimbostratus Spiderman (COCI20_spiderman) C++17
70 / 70
123 ms 21116 KB
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
using lint = long long;
const int maxn = 3e5 + 5;
const int maxk = 1e6 + 5;
const int inf = 1e9 + 5;
const int mod = 1e9 + 7;

int n, k;
int a[maxn];
int freq[maxk];
int ans[maxk];

signed main() {
	#ifdef Local
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		freq[a[i]]++;
	}
	for(int i = 1; i <= 1e6; i++) {
		if(k >= i)
			continue;
		for(int j = 0; i * j + k <= 1e6 ; j++)
			ans[i * j + k] += freq[i] - (i * j + k == i);
	}
	for(int i = 1; i <= n; i++)
		cout << ans[a[i]] << " ";
}
# Verdict Execution time Memory Grader output
1 Correct 55 ms 11092 KB Output is correct
2 Correct 74 ms 9904 KB Output is correct
3 Correct 85 ms 12920 KB Output is correct
4 Correct 104 ms 16204 KB Output is correct
5 Correct 101 ms 17516 KB Output is correct
6 Correct 112 ms 21116 KB Output is correct
7 Correct 70 ms 17520 KB Output is correct
8 Correct 72 ms 17532 KB Output is correct
9 Correct 112 ms 20968 KB Output is correct
10 Correct 123 ms 20940 KB Output is correct