# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334023 | 2020-12-08T06:22:40 Z | ronnith | Spiderman (COCI20_spiderman) | C++14 | 1303 ms | 6380 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 if(fac > 0){ 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); } else { printf("0 "); } } puts(""); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 4204 KB | Output is correct |
2 | Correct | 9 ms | 4204 KB | Output is correct |
3 | Correct | 348 ms | 4972 KB | Output is correct |
4 | Correct | 993 ms | 6380 KB | Output is correct |
5 | Correct | 390 ms | 4844 KB | Output is correct |
6 | Correct | 1129 ms | 6380 KB | Output is correct |
7 | Correct | 437 ms | 4844 KB | Output is correct |
8 | Correct | 439 ms | 4972 KB | Output is correct |
9 | Correct | 1303 ms | 6380 KB | Output is correct |
10 | Correct | 1291 ms | 6252 KB | Output is correct |