Submission #844337

# Submission time Handle Problem Language Result Execution time Memory
844337 2023-09-05T12:25:09 Z vjudge1 Spiderman (COCI20_spiderman) C++17
21 / 70
822 ms 27476 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll LOGN = 20;
const ll MAXN = 1e6 + 5;

vector<ll> A, A2;
ll divCnt[MAXN], newCnt[MAXN];
map<ll,ll> mp;
int main() {
	fast
	ll N, K;
	cin >> N >> K;

	A = vector<ll>(N+1);
	A2 = vector<ll>(N+1);
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		mp[A[i]]++;
		A2[i] = A[i];
	}
	sort(A2.begin(), A2.end());

	for (int i = 1; i <= N; i++)
		divCnt[A[i]]++;

	for (int i = 1; i <= N; i++) {
		if (A[i] <= K)
			continue;
		for (int j = A[i]; j <= MAXN; j+=A[i]) {
			newCnt[j] += divCnt[A[i]];
		}
	}

	for (int i = 1; i <= N; i++) {
		if (A[i] == K) {
			int Q = upper_bound(A2.begin(), A2.end(), A[i]) - A2.begin();
			cout << N - Q + 1 << " ";
		} else if (A[i] < K)
			cout << "0 ";
		else {
			ll ans = newCnt[A[i] - K];
			cout << ans << " ";
		}
	}
	cout << "\n"; 
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 15448 KB Output is correct
2 Incorrect 11 ms 15304 KB Output isn't correct
3 Incorrect 394 ms 17528 KB Output isn't correct
4 Incorrect 822 ms 21480 KB Output isn't correct
5 Incorrect 67 ms 23936 KB Output isn't correct
6 Incorrect 164 ms 27476 KB Output isn't correct
7 Correct 62 ms 24092 KB Output is correct
8 Correct 65 ms 23940 KB Output is correct
9 Incorrect 170 ms 27412 KB Output isn't correct
10 Incorrect 156 ms 27220 KB Output isn't correct