Submission #844455

# Submission time Handle Problem Language Result Execution time Memory
844455 2023-09-05T13:17:39 Z vjudge1 Spiderman (COCI20_spiderman) C++17
14 / 70
106 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];
	}
	alr*=say[k]-1;
	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:18: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]
   18 |  for (int i = k+1; i < say.size(); i++){
      |                    ~~^~~~~~~~~~~~
spiderman.cpp:19: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]
   19 |   for (int j = i; j < say.size(); j+=i){
      |                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 15960 KB Output isn't correct
2 Incorrect 16 ms 15960 KB Output isn't correct
3 Incorrect 44 ms 16976 KB Output isn't correct
4 Incorrect 101 ms 19304 KB Output isn't correct
5 Correct 46 ms 16976 KB Output is correct
6 Correct 100 ms 19280 KB Output is correct
7 Incorrect 46 ms 16976 KB Output isn't correct
8 Incorrect 44 ms 16972 KB Output isn't correct
9 Incorrect 101 ms 19052 KB Output isn't correct
10 Incorrect 106 ms 19024 KB Output isn't correct