Submission #844464

# Submission time Handle Problem Language Result Execution time Memory
844464 2023-09-05T13:19:42 Z vjudge1 Spiderman (COCI20_spiderman) C++17
49 / 70
780 ms 6320 KB
// clang-format off
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define lg2(x) (63 - __builtin_clzll(x))
#define db cerr << "BREAK\n"
#define fp(...) fprintf(stderr, __VA_ARGS__)
#define rs(a) a.resize(n)
#define hizli cin.tie(0);ios_base::sync_with_stdio(0)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(a, b) for (int a = 0; a < b; a++)
#define af(x) for(auto&a:x)fp("%d ",a);fp("\n")
#define ff first
#define ss second
#define zekochain main
// clang-format on
template <typename... Args> void in(Args &&...args) {
  (std::cin >> ... >> args);
}
const int N = 2e5 + 5, MOD = 1e9 + 7;
int zekochain() {
  hizli;
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  vector<int> mark(1e6 + 1);
  int mx = 0;
  bool in = 0;
  for (auto &a : v) {
    cin >> a;
    if (a == k) {
      in = 1;
    }
    mx = max(mx, a);
  }
  mark[0] = n;
  for (int i = 0; i < n; i++) {
    if (v[i] < k) {
      mark[0]--;
      continue;
    }
    for (int j = v[i]; j <= mx - k + 2; j += v[i]) {
      mark[j]++;
    }
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    if (v[i] < k) {
      cout << ans << endl;
      continue;
    }
    if (v[i] >= k) {
      ans = mark[v[i] - k];
    }
    if (in && v[i] % k == 0) {
      ans--;
    }
    cout << ans << " ";
  }
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4188 KB Output is correct
2 Correct 9 ms 4188 KB Output is correct
3 Incorrect 359 ms 5008 KB Output isn't correct
4 Correct 780 ms 6304 KB Output is correct
5 Incorrect 27 ms 4952 KB Output isn't correct
6 Incorrect 85 ms 6320 KB Output isn't correct
7 Correct 27 ms 4948 KB Output is correct
8 Correct 25 ms 4952 KB Output is correct
9 Correct 81 ms 6304 KB Output is correct
10 Correct 75 ms 6212 KB Output is correct