답안 #231818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231818 2020-05-15T00:35:54 Z CodeTiger927 Spiderman (COCI20_spiderman) C++14
56 / 70
1688 ms 14852 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 768 KB Output is correct
2 Correct 12 ms 640 KB Output is correct
3 Correct 395 ms 1912 KB Output is correct
4 Correct 1134 ms 4348 KB Output is correct
5 Incorrect 501 ms 8248 KB Output isn't correct
6 Incorrect 1454 ms 10556 KB Output isn't correct
7 Correct 616 ms 12980 KB Output is correct
8 Correct 616 ms 13192 KB Output is correct
9 Correct 1688 ms 14852 KB Output is correct
10 Correct 1665 ms 14852 KB Output is correct