Submission #844361

# Submission time Handle Problem Language Result Execution time Memory
844361 2023-09-05T12:42:55 Z vjudge1 Spiderman (COCI20_spiderman) C++17
49 / 70
805 ms 6556 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+1; 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 5 ms 4192 KB Output is correct
2 Correct 11 ms 4184 KB Output is correct
3 Incorrect 352 ms 4948 KB Output isn't correct
4 Correct 805 ms 6556 KB Output is correct
5 Incorrect 26 ms 4952 KB Output isn't correct
6 Incorrect 81 ms 6304 KB Output isn't correct
7 Correct 22 ms 4956 KB Output is correct
8 Correct 24 ms 4772 KB Output is correct
9 Correct 80 ms 6304 KB Output is correct
10 Correct 74 ms 6052 KB Output is correct