Submission #1109614

#TimeUsernameProblemLanguageResultExecution timeMemory
11096140pt1mus23Brunhilda’s Birthday (BOI13_brunhilda)C++14
8.10 / 100
112 ms88248 KiB
#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 = 1e7 +10, inf = INT_MAX, LG = 20; int dp[sze]; void fast(){ int n,q; cin>>n>>q; multiset<int> ans; int mx = 0; vector<pair<int,int>> ev; for(int i=1;i<=n;i++){ int p;cin>>p; // event[p].pb(p); ev.pb({p,p}); mx=max(mx,p); } vector<int> primus; int j=0; pair<int,int> beg; for(int i =1;i<sze;i++){ dp[i]=inf; primus.clear(); while(j<ev.size()){ beg = ev[j]; if(beg.first != i){ break; } j++; primus.pb(beg.second); if(i != beg.second){ ans.erase(ans.find(dp[i - beg.second])); } } if( i < mx ){ dp[i]=1; } else if(!ans.empty()){ dp[i]= (*ans.begin())+1; } if(dp[i]<inf){ for(auto v:primus){ ans.ins(dp[i]); ev.pb({i + v,v}); } } } 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; }

Compilation message (stderr)

brunhilda.cpp: In function 'void fast()':
brunhilda.cpp:30:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         while(j<ev.size()){
      |               ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...