Submission #580923

# Submission time Handle Problem Language Result Execution time Memory
580923 2022-06-22T06:24:19 Z AGE Spiderman (COCI20_spiderman) C++14
70 / 70
201 ms 29352 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pb push_back

using namespace std;
const int N=1e6,M=2e3,mod=1e9+7;

int a[N],seive[N+10],ans[N],mp[N+10],mp2[N+10];
 main()
{
    int n,m;
    cin>>n>>m;

    for(int i=0;i<n;i++)
        cin>>a[i],mp[a[i]]++;

    for(int i=1;i<=1e6;i++)
        mp2[i]+=mp[i]+mp2[i-1];

    for(int i=1;i<=1e6;i++){

        if(i<=m)
            continue;

        for(int j=i;j<=1e6;j+=i){

            seive[j]+=mp[i];

        }

    }




    for(int i=0;i<n;i++){

        if(a[i]<m)
            continue;

        if(a[i]==m){
            ans[i]=n-mp2[a[i]];
            continue;
        }

        if(m==0)
            ans[i]=seive[a[i]-m]-1;
        else
            ans[i]=seive[a[i]-m];

    }

    for(int i=0;i<n;i++)
        cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}

Compilation message

spiderman.cpp:11:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 |  main()
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Correct 45 ms 18936 KB Output is correct
2 Correct 80 ms 17748 KB Output is correct
3 Correct 113 ms 20892 KB Output is correct
4 Correct 187 ms 24652 KB Output is correct
5 Correct 103 ms 25712 KB Output is correct
6 Correct 201 ms 29352 KB Output is correct
7 Correct 89 ms 25556 KB Output is correct
8 Correct 112 ms 25540 KB Output is correct
9 Correct 188 ms 29184 KB Output is correct
10 Correct 180 ms 29132 KB Output is correct