Submission #1109591

# Submission time Handle Problem Language Result Execution time Memory
1109591 2024-11-07T06:40:20 Z 0pt1mus23 Brunhilda’s Birthday (BOI13_brunhilda) C++14
0 / 100
154 ms 262144 KB
#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];
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;
    for(int i=1;i<=n;i++){
        int p;cin>>p;
        event[p].pb({p,p});
        mx=max(mx,p);
    }
    for(int i =1;i<sze;i++){
        for(auto v:event[i]){
            if(dp[v.first]<inf){
                ans.erase(ans.find(dp[v.first]));
            }
        }
        if( ans.empty() ){
            if(i < mx){
                dp[i]=1;
            }
        }
        else{
            dp[i]= (*ans.begin())+1;
        }
        if(dp[i]<inf){
            for(auto v:event[i]){
                ans.ins(dp[i]);
                event[i + v.second].pb({i,v.second});
            }
        }
    }


    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 time Memory Grader output
1 Runtime error 123 ms 262144 KB Execution killed with signal 9
2 Runtime error 131 ms 262144 KB Execution killed with signal 9
3 Runtime error 136 ms 262144 KB Execution killed with signal 9
4 Runtime error 129 ms 262144 KB Execution killed with signal 9
5 Runtime error 128 ms 262144 KB Execution killed with signal 9
6 Runtime error 129 ms 262144 KB Execution killed with signal 9
7 Runtime error 135 ms 262144 KB Execution killed with signal 9
8 Runtime error 129 ms 262144 KB Execution killed with signal 9
9 Runtime error 134 ms 262144 KB Execution killed with signal 9
10 Runtime error 132 ms 262144 KB Execution killed with signal 9
11 Runtime error 131 ms 262144 KB Execution killed with signal 9
12 Runtime error 132 ms 262144 KB Execution killed with signal 9
13 Runtime error 136 ms 262144 KB Execution killed with signal 9
14 Runtime error 128 ms 262144 KB Execution killed with signal 9
15 Runtime error 153 ms 262144 KB Execution killed with signal 9
16 Runtime error 140 ms 262144 KB Execution killed with signal 9
17 Runtime error 130 ms 262144 KB Execution killed with signal 9
18 Runtime error 125 ms 262144 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 129 ms 262144 KB Execution killed with signal 9
2 Runtime error 134 ms 262144 KB Execution killed with signal 9
3 Runtime error 142 ms 262144 KB Execution killed with signal 9
4 Runtime error 139 ms 262144 KB Execution killed with signal 9
5 Runtime error 134 ms 262144 KB Execution killed with signal 9
6 Runtime error 141 ms 262144 KB Execution killed with signal 9
7 Runtime error 140 ms 262144 KB Execution killed with signal 9
8 Runtime error 125 ms 262144 KB Execution killed with signal 9
9 Runtime error 146 ms 262144 KB Execution killed with signal 9
10 Runtime error 133 ms 262144 KB Execution killed with signal 9
11 Runtime error 136 ms 262144 KB Execution killed with signal 9
12 Runtime error 144 ms 262144 KB Execution killed with signal 9
13 Runtime error 154 ms 262144 KB Execution killed with signal 9
14 Runtime error 148 ms 262144 KB Execution killed with signal 9
15 Runtime error 147 ms 262144 KB Execution killed with signal 9
16 Runtime error 141 ms 262144 KB Execution killed with signal 9
17 Runtime error 149 ms 262144 KB Execution killed with signal 9
18 Runtime error 145 ms 262144 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 152 ms 262144 KB Execution killed with signal 9
2 Runtime error 145 ms 262144 KB Execution killed with signal 9
3 Runtime error 140 ms 262144 KB Execution killed with signal 9
4 Runtime error 134 ms 262144 KB Execution killed with signal 9
5 Runtime error 143 ms 262144 KB Execution killed with signal 9
6 Runtime error 134 ms 262144 KB Execution killed with signal 9
7 Runtime error 133 ms 262144 KB Execution killed with signal 9
8 Runtime error 128 ms 262144 KB Execution killed with signal 9
9 Runtime error 134 ms 262144 KB Execution killed with signal 9
10 Runtime error 135 ms 262144 KB Execution killed with signal 9
11 Runtime error 123 ms 262144 KB Execution killed with signal 9
12 Runtime error 133 ms 262144 KB Execution killed with signal 9
13 Runtime error 130 ms 262144 KB Execution killed with signal 9
14 Runtime error 147 ms 262144 KB Execution killed with signal 9
15 Runtime error 133 ms 262144 KB Execution killed with signal 9
16 Runtime error 133 ms 262144 KB Execution killed with signal 9
17 Runtime error 131 ms 262144 KB Execution killed with signal 9
18 Runtime error 126 ms 262144 KB Execution killed with signal 9
19 Runtime error 128 ms 262144 KB Execution killed with signal 9
20 Runtime error 126 ms 262144 KB Execution killed with signal 9
21 Runtime error 123 ms 262144 KB Execution killed with signal 9
22 Runtime error 132 ms 262144 KB Execution killed with signal 9
23 Runtime error 130 ms 262144 KB Execution killed with signal 9
24 Runtime error 128 ms 262144 KB Execution killed with signal 9
25 Runtime error 120 ms 262144 KB Execution killed with signal 9
26 Runtime error 115 ms 262144 KB Execution killed with signal 9
27 Runtime error 123 ms 262144 KB Execution killed with signal 9
28 Runtime error 128 ms 262144 KB Execution killed with signal 9
29 Runtime error 125 ms 262144 KB Execution killed with signal 9
30 Runtime error 120 ms 262144 KB Execution killed with signal 9
31 Runtime error 114 ms 262144 KB Execution killed with signal 9
32 Runtime error 119 ms 262144 KB Execution killed with signal 9
33 Runtime error 120 ms 262144 KB Execution killed with signal 9
34 Runtime error 116 ms 262144 KB Execution killed with signal 9
35 Runtime error 125 ms 262144 KB Execution killed with signal 9
36 Runtime error 131 ms 262144 KB Execution killed with signal 9
37 Runtime error 137 ms 262144 KB Execution killed with signal 9
38 Runtime error 123 ms 262144 KB Execution killed with signal 9
39 Runtime error 115 ms 262144 KB Execution killed with signal 9
40 Runtime error 112 ms 262144 KB Execution killed with signal 9
41 Runtime error 124 ms 262144 KB Execution killed with signal 9
42 Runtime error 120 ms 262144 KB Execution killed with signal 9