Submission #844370

# Submission time Handle Problem Language Result Execution time Memory
844370 2023-09-05T12:46:15 Z vjudge1 Spiderman (COCI20_spiderman) C++17
56 / 70
125 ms 25548 KB
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define N 1000005
using namespace std;
vector <int> cnt(N), ans(N), values, arr(N);

int32_t main(){
	fast
	int n, k;
	cin>>n>>k;
	for(int i = 0; i < n; i++) {
		cin>>arr[i];
		int in = arr[i];
		if(!cnt[in]) {
			values.push_back(in);
		}
		cnt[in]++;
	}
	sort(values.begin(), values.end());
	reverse(values.begin(), values.end());
	//k kalanını unutma
	for(auto val:values) {
		//cout<<val<<":\n";
		if(k == 0) {
			ans[val] += cnt[val] - 1;
		}
		if(k >= val) continue;
		for(int i = 0; i <= values[0] - k; i += val) {
			ans[i + k] += cnt[val];
		}
	}
	for(int i = 0; i < n; i++) {
		cout<<ans[arr[i]]<<" ";
	}

}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23896 KB Output is correct
2 Correct 13 ms 23900 KB Output is correct
3 Correct 27 ms 24252 KB Output is correct
4 Correct 48 ms 24916 KB Output is correct
5 Incorrect 49 ms 25052 KB Output isn't correct
6 Incorrect 95 ms 25516 KB Output isn't correct
7 Correct 51 ms 25048 KB Output is correct
8 Correct 84 ms 24900 KB Output is correct
9 Correct 125 ms 25548 KB Output is correct
10 Correct 121 ms 25280 KB Output is correct