Submission #249691

#TimeUsernameProblemLanguageResultExecution timeMemory
249691dvdg6566Spiderman (COCI20_spiderman)C++14
70 / 70
1769 ms128120 KiB
#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 timeMemoryGrader output
Fetching results...