Submission #844364

# Submission time Handle Problem Language Result Execution time Memory
844364 2023-09-05T12:44:27 Z vjudge1 Spiderman (COCI20_spiderman) C++17
0 / 70
9 ms 14728 KB
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define N 300005
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 Runtime error 9 ms 14684 KB Execution killed with signal 11
2 Runtime error 8 ms 14684 KB Execution killed with signal 11
3 Runtime error 9 ms 14680 KB Execution killed with signal 11
4 Runtime error 8 ms 14684 KB Execution killed with signal 11
5 Runtime error 8 ms 14680 KB Execution killed with signal 11
6 Runtime error 8 ms 14684 KB Execution killed with signal 11
7 Runtime error 8 ms 14684 KB Execution killed with signal 11
8 Runtime error 8 ms 14728 KB Execution killed with signal 11
9 Runtime error 8 ms 14684 KB Execution killed with signal 11
10 Runtime error 8 ms 14684 KB Execution killed with signal 11