Submission #334022

# Submission time Handle Problem Language Result Execution time Memory
334022 2020-12-08T06:20:13 Z ronnith Spiderman (COCI20_spiderman) C++14
21 / 70
1286 ms 8428 KB
#include <bits/stdc++.h>

typedef long long ll;
#define mk make_pair
#define f first
#define s second

using namespace std;

int main(){
	int n, k;
	scanf("%d%d", &n,&k);
	int h[n];
	int mx = 0;
	for(int i = 0;i < n;i ++){
		scanf("%d", &h[i]);
		mx = max(mx, h[i]);
	}
	int fr[mx + 1];
	fill(fr, fr + mx + 1, 0);
	int cnt = 0;
	for(int i = 0;i < n;i ++){
		if(h[i] > k){
			fr[h[i]] ++;
			cnt ++;
		}
	}
	for(int i = 0;i < n;i ++){
		int fac = h[i] - k;
		if(fac == 0){
			printf("%d ", cnt);
		} else {
			int ans = 0;
			for(int j = 1;j * j <= fac;j ++){
				if(fac % j == 0){
					ans += fr[j];
					if(j * j != fac)ans += fr[fac / j];
				}
			}
			if(fac % h[i] == 0)ans --;
			printf("%d ", ans);
		}
	}
	puts("");
	return 0;
}

Compilation message

spiderman.cpp: In function 'int main()':
spiderman.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d%d", &n,&k);
      |  ~~~~~^~~~~~~~~~~~~~~
spiderman.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |   scanf("%d", &h[i]);
      |   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 4204 KB Output isn't correct
2 Incorrect 9 ms 4204 KB Output isn't correct
3 Correct 338 ms 5612 KB Output is correct
4 Incorrect 986 ms 8320 KB Output isn't correct
5 Correct 384 ms 5484 KB Output is correct
6 Correct 1130 ms 8428 KB Output is correct
7 Incorrect 433 ms 5484 KB Output isn't correct
8 Incorrect 436 ms 5484 KB Output isn't correct
9 Incorrect 1286 ms 8188 KB Output isn't correct
10 Incorrect 1282 ms 8300 KB Output isn't correct