# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
249691 | dvdg6566 | Spiderman (COCI20_spiderman) | C++14 | 1769 ms | 128120 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN=300001;
const ll MAXK=1000001;
const ll INF = 1e9;
const ll MOD = 1e9+7;
int A[MAXN];
int B[MAXK];
int res[MAXN];
int dp[MAXK];
int N,K,a;
vi V[MAXK];
int calc(int x){
if(dp[x]!=-1)return dp[x];
dp[x]=0;
for(auto i:V[x])dp[x]+=B[i];
if(K==0)--dp[x];
return dp[x];
}
int main(){
for(int i=1;i<=MAXK;++i)for(int j=i;j<=MAXK;j+=i){
V[j].pb(i);
}
cin>>N>>K;
memset(res,-1,sizeof(res));
memset(dp,-1,sizeof(dp));
int x=0;
for(int i=1;i<=N;++i){
cin>>A[i];
if(A[i]<K)res[i]=0;
if (A[i]>K){
++x;
B[A[i]]++;
}
}
for(int i=1;i<=N;++i)if(A[i]==K){
res[i]=x;
}
for(int i=1;i<=N;++i)if(res[i]==-1){
res[i]=calc(A[i]-K);
}
for(int i=1;i<=N;++i)cout<<res[i]<<' ';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |