Submission #231820

# Submission time Handle Problem Language Result Execution time Memory
231820 2020-05-15T00:40:22 Z CodeTiger927 Spiderman (COCI20_spiderman) C++14
70 / 70
1654 ms 14936 KB
using namespace std;

#include <iostream>
#include <unordered_map>
#include <cmath>

unordered_map<int,int> us;
int zero = 0;
int arr[300005];
int ans[300005];

int main() {
	int N,K;
	cin >> N >> K;
	for(int i = 0;i < N;i++) {
		int cur;
		cin >> cur;
		arr[i] = cur;
		us[cur]++;
		if(cur > K) {
			zero++;
		}
	}
	for(int i = 0;i < N;++i) {
		int cur = arr[i] - K;
		if(cur < 0) {
			continue;
		}else if(cur == 0) {
			ans[i] = zero;
			continue;
		}
		for(int j = 1;j <= sqrt(cur);++j) {
			if(cur % j == 0) {
				int counter = cur / j;
				if(j > K) {
					ans[i] += us[j];
				}
				if(counter > K && counter != j) {
					ans[i] += us[counter];
				}
			}
		}
		if(K == 0) {
			--ans[i];
		}
	}
	for(int i = 0;i < N;i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 768 KB Output is correct
2 Correct 13 ms 640 KB Output is correct
3 Correct 391 ms 1912 KB Output is correct
4 Correct 1123 ms 4128 KB Output is correct
5 Correct 503 ms 7992 KB Output is correct
6 Correct 1418 ms 9756 KB Output is correct
7 Correct 610 ms 13112 KB Output is correct
8 Correct 603 ms 12984 KB Output is correct
9 Correct 1654 ms 14936 KB Output is correct
10 Correct 1648 ms 14824 KB Output is correct