Submission #844625

# Submission time Handle Problem Language Result Execution time Memory
844625 2023-09-05T14:56:01 Z vjudge1 Spiderman (COCI20_spiderman) C++17
49 / 70
766 ms 6296 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 (v[i] < k) {
      mark[0]--;
      continue;
    }
    if(k==0)mark[0]--;
    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 4188 KB Output is correct
3 Incorrect 353 ms 5008 KB Output isn't correct
4 Correct 766 ms 6296 KB Output is correct
5 Incorrect 27 ms 4952 KB Output isn't correct
6 Incorrect 79 ms 6224 KB Output isn't correct
7 Correct 21 ms 4948 KB Output is correct
8 Correct 24 ms 4792 KB Output is correct
9 Correct 80 ms 6224 KB Output is correct
10 Correct 71 ms 6224 KB Output is correct