Submission #1182090

#TimeUsernameProblemLanguageResultExecution timeMemory
118209012345678Spiderman (COCI20_spiderman)C++20
56 / 70
59 ms10056 KiB
#include <bits/stdc++.h>

using namespace std;

const int nx=1e6+5;

int n, k, h[nx], x, cnt[nx], f[nx];

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>k;
    if (k==0) cout<<1/0;
    for (int i=1; i<=n; i++) cin>>h[i], x+=(h[i]>k);
    for (int i=1; i<=n; i++) if (h[i]>k) cnt[h[i]]++;
    for (int i=1; i<nx; i++) for (int j=i; j<nx; j+=i) f[j]+=cnt[i];
    for (int i=1; i<=n; i++)
    {
        if (h[i]==k) cout<<x<<' ';
        else if (h[i]>k) cout<<f[h[i]-k]-(k==0?cnt[h[i]-k]:0)<<' ';
        else cout<<0<<' ';
    }
}

Compilation message (stderr)

spiderman.cpp: In function 'int main()':
spiderman.cpp:13:22: warning: division by zero [-Wdiv-by-zero]
   13 |     if (k==0) cout<<1/0;
      |                     ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...