Submission #844428

# Submission time Handle Problem Language Result Execution time Memory
844428 2023-09-05T13:09:29 Z vjudge1 Spiderman (COCI20_spiderman) C++17
49 / 70
1095 ms 11532 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];
	for (int i = 0; i < n; ++i)
	{
		if (arr[i]==k){
			cout<<alr<<" ";
			continue;
		}
		if (arr[i]<k){
			cout<<0<<" ";
			continue;
		}
		arr[i]-=k;
		int ans = 0;
		for (int j = 1; j*j <= arr[i]; j++){
			if (arr[i]%j) continue;
			if (j>k) ans+=say[j];
			if (arr[i]/j>k && arr[i]/j!=j) ans+=say[arr[i]/j];
		}
		cout<<ans<<" ";
	}
	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++){
      |                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8280 KB Output is correct
2 Correct 7 ms 8284 KB Output is correct
3 Incorrect 288 ms 9292 KB Output isn't correct
4 Correct 823 ms 11532 KB Output is correct
5 Incorrect 322 ms 9208 KB Output isn't correct
6 Incorrect 953 ms 11500 KB Output isn't correct
7 Correct 370 ms 9296 KB Output is correct
8 Correct 371 ms 9052 KB Output is correct
9 Correct 1084 ms 11476 KB Output is correct
10 Correct 1095 ms 11340 KB Output is correct