Submission #844458

# Submission time Handle Problem Language Result Execution time Memory
844458 2023-09-05T13:18:00 Z vjudge1 Spiderman (COCI20_spiderman) C++17
70 / 70
102 ms 19304 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
	int n,k;cin>>n>>k;
	vector<int> arr(n);
	vector<int> say(1000023,0);
	for (int i = 0; i < n; i++){
		cin>>arr[i];
		say[arr[i]]++;
	}
	int alr = 0;
	for (int i = k+1; i < say.size(); i++){
		alr+=say[i];
	}
	vector<int> ans(say.size());
	for (int i = k+1; i < say.size(); i++){
		for (int j = i; j < say.size(); j+=i){
			ans[j]+=say[i];
		}
	}
	for (int i = 0; i < n; ++i)
	{
		if (arr[i]==k){
			cout<<alr<<" ";
			continue;
		}
		if (arr[i]<k){
			cout<<0<<" ";
			continue;
		}
		if (k==0){
			cout<<ans[arr[i]-k]-1<<" ";
		}
		else cout<<ans[arr[i]-k]<<" ";
	}
	cout<<endl;
}

Compilation message

spiderman.cpp: In function 'int32_t main()':
spiderman.cpp:13:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for (int i = k+1; i < say.size(); i++){
      |                    ~~^~~~~~~~~~~~
spiderman.cpp:17:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i = k+1; i < say.size(); i++){
      |                    ~~^~~~~~~~~~~~
spiderman.cpp:18:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for (int j = i; j < say.size(); j+=i){
      |                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 15964 KB Output is correct
2 Correct 18 ms 16120 KB Output is correct
3 Correct 44 ms 16992 KB Output is correct
4 Correct 95 ms 19204 KB Output is correct
5 Correct 58 ms 16972 KB Output is correct
6 Correct 98 ms 19304 KB Output is correct
7 Correct 43 ms 16984 KB Output is correct
8 Correct 45 ms 16992 KB Output is correct
9 Correct 102 ms 19044 KB Output is correct
10 Correct 101 ms 19044 KB Output is correct