Submission #925228

#TimeUsernameProblemLanguageResultExecution timeMemory
92522812345678Brunhilda’s Birthday (BOI13_brunhilda)C++17
27.94 / 100
191 ms159316 KiB
#include <bits/stdc++.h> using namespace std; const int nx=1e7+5; int dp[nx], n, m, x, q, p, res[nx], t, cnt; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>m>>q; for (int i=0; i<m; i++) { cin>>x; for (int j=x; j<nx; j+=x) dp[j]=x; } for (int i=x; i<nx; i++) res[i]=-1; for (int i=0; i<x; i++) res[i]=1; t=1; while (p<nx) { int mx=x; t++; for (int i=p; i<x; i++) mx=max(mx, i+dp[i]); for (int i=x; i<min(nx-1, mx); i++) res[i]=t; if (mx==x) break; p=x; x=mx; } //for (int i=0; i<35; i++) cout<<i<<' '<<res[i]<<'\n'; while (q--) { cin>>x; if (res[x]==-1) cout<<"oo\n"; else cout<<res[x]<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...