답안 #440627

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
440627 2021-07-02T14:52:20 Z Wasif_Jamil Spiderman (COCI20_spiderman) C++17
0 / 70
2000 ms 124084 KB
#include<bits/stdc++.h>
using namespace std;
vector<int>divisors[1000001];

int main(){
	for(int i=1; i<=1000000; i++){
		for(int j=i; j<=1000000; j+=i){
			divisors[j].push_back(i);
		}
	}
	int n, k; 
	cin >> n >> k;
	vector< pair<int, int> >v(n);
	unordered_map<int, int>mp;
	for(int i=0; i<n; i++){
		cin >> v[i].first;
		v[i].second = i;
		mp[v[i].first]++;
	}
	sort(v.begin(), v.end());
	vector<int>d(n);
	for(int i=0; i<n; i++){
		//cout << v[i] << '\n';
		int val = v[i].first - k;
		if(val <= 0){
			if(k == v[i].first){
				d[v[i].second] = n-i-1;
			}else {
				d[v[i].second] = 0;
			}
		}
		else {
			int ans = 0;
			for(int e:divisors[val]){
				if(e==k)continue;
				ans += mp[e];
			}
			d[v[i].second] = ans;
		}
	}
	for(int e:d)cout << e << " ";
	return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Incorrect 1765 ms 114928 KB Output isn't correct
2 Incorrect 1737 ms 114980 KB Output isn't correct
3 Incorrect 1829 ms 116516 KB Output isn't correct
4 Incorrect 1985 ms 119748 KB Output isn't correct
5 Incorrect 1983 ms 117832 KB Output isn't correct
6 Execution timed out 2072 ms 120996 KB Time limit exceeded
7 Execution timed out 2063 ms 121296 KB Time limit exceeded
8 Execution timed out 2070 ms 121188 KB Time limit exceeded
9 Execution timed out 2091 ms 124060 KB Time limit exceeded
10 Execution timed out 2076 ms 124084 KB Time limit exceeded