제출 #1109603

#제출 시각아이디문제언어결과실행 시간메모리
11096030pt1mus23Brunhilda’s Birthday (BOI13_brunhilda)C++14
20 / 100
44 ms3780 KiB
// test idea #include <bits/stdc++.h> using namespace std; #define int long long int #define ins insert #define pb push_back #define endl '\n' #define putr(x) cout<<x<<endl;return; #define all(x) x.begin(),x.end() int nxt(){ int x;cin>>x; return x; } const int mod = 1e9 +7, sze = 1e4 +10, inf = INT_MAX, LG = 20; int dp[sze]; vector<pair<int,int>> event[sze]; void fast(){ for(int i=1;i<sze;i++){ dp[i]=inf; } int n,q; cin>>n>>q; multiset<int> ans; int mx = 0; vector<int> arr; for(int i=1;i<=n;i++){ int p;cin>>p; // event[p].pb({p,p}); mx=max(mx,p); arr.pb(p); } dp[0]=0; for(int i=1;i<sze;i++){ for(auto v:arr){ if(v>i){ dp[i]=1; break; } int x = max((int)0, v*(i/v)); dp[i]=min(dp[i],dp[x] +1); // cout<<i<<" "<<v<< " "<<dp[x]+1<<endl; } } while(q--){ int v; cin>>v; if(dp[v]>=inf){ cout<<"oo"<<endl; } else{ cout<<dp[v]<<endl; } } } signed main(){ // ios::sync_with_stdio(0); // cin.tie(0); // cout.tie(0); int tt = 1; // cin>>tt; while(tt--){ fast(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...