Submission #844448

# Submission time Handle Problem Language Result Execution time Memory
844448 2023-09-05T13:15:44 Z vjudge1 Spiderman (COCI20_spiderman) C++17
70 / 70
55 ms 10320 KB
// author: erray
#include <bits/stdc++.h>

#ifdef DEBUG
  #include "debug.h"
#else
  #define debug(...) void(37)
#endif

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  int MAX = *max_element(H.begin(), H.end());
  vector<int> freq(MAX + 1);
  for (auto x : H) {
    freq[x] += 1;
  }
  vector<int> divs(MAX + 1);
  for (int i = K + 1; i <= MAX; ++i) {
    for (int j = 0; j <= MAX; j += i) {
      divs[j] += freq[i];
    }
  }
  for (int i = 0; i < N; ++i) {
    cout << (H[i] < K ? 0 : divs[H[i] - K] - (K == 0)) << " \n"[i == N - 1];
  }
}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 8288 KB Output is correct
2 Correct 18 ms 8284 KB Output is correct
3 Correct 27 ms 8928 KB Output is correct
4 Correct 50 ms 10320 KB Output is correct
5 Correct 28 ms 8796 KB Output is correct
6 Correct 52 ms 10224 KB Output is correct
7 Correct 24 ms 8796 KB Output is correct
8 Correct 27 ms 8796 KB Output is correct
9 Correct 52 ms 10068 KB Output is correct
10 Correct 55 ms 9996 KB Output is correct