Submission #844626

# Submission time Handle Problem Language Result Execution time Memory
844626 2023-09-05T14:56:37 Z vjudge1 Spiderman (COCI20_spiderman) C++17
49 / 70
784 ms 6484 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
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(k==0)mark[0]--;
    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 (k!=0 and in && v[i] % k == 0) {
      ans--;
    }
    cout << ans << " ";
  }
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4188 KB Output is correct
2 Correct 9 ms 4392 KB Output is correct
3 Incorrect 372 ms 5204 KB Output isn't correct
4 Correct 784 ms 6320 KB Output is correct
5 Incorrect 26 ms 4776 KB Output isn't correct
6 Incorrect 82 ms 6228 KB Output isn't correct
7 Correct 21 ms 4776 KB Output is correct
8 Correct 24 ms 4944 KB Output is correct
9 Correct 89 ms 6484 KB Output is correct
10 Correct 74 ms 6044 KB Output is correct