Submission #553583

# Submission time Handle Problem Language Result Execution time Memory
553583 2022-04-26T09:46:34 Z new_acc Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
288 ms 262144 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e6+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
int dp[N*10],ile[N*10],zap[N],t[N];
vi dziel[N*10];
void solve(){
	int n,m;
	cin>>m>>n;
	for(int i=1;i<=m;i++) cin>>t[i];
	int maxi=0;
	for(int i=1;i<=n;i++){
		cin>>zap[i];
		maxi=max(maxi,zap[i]);
	}
	for(int i=1;i<=m;i++)
		for(int j=t[i];j<=maxi;j+=t[i]) dziel[j].push_back(t[i]);
	deque<pair<int,int > >curr;
	for(int i=1;i<=m;i++) curr.push_back({0,t[i]});
	for(int i=1;i<=maxi;i++){
		for(auto u:dziel[i]) ile[u]++;
		while(curr.size() and ile[curr[0].se]>0) ile[curr[0].se]--,curr.pop_front();
		if(!curr.size()) dp[i]=INFi;
		else dp[i]=min(curr[0].fi+1,INFi);
		for(auto u:dziel[i]) curr.push_back({dp[i],u});
	}
	for(int i=1;i<=n;i++){
		if(dp[zap[i]]==INFi) cout<<"oo\n";
	 	else cout<<dp[zap[i]]<<"\n";
	}
}
int main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	solve();
}
# Verdict Execution time Memory Grader output
1 Correct 123 ms 235256 KB Output is correct
2 Correct 124 ms 235444 KB Output is correct
3 Correct 119 ms 235400 KB Output is correct
4 Correct 135 ms 235260 KB Output is correct
5 Correct 122 ms 235176 KB Output is correct
6 Correct 118 ms 235304 KB Output is correct
7 Correct 116 ms 235412 KB Output is correct
8 Correct 143 ms 235424 KB Output is correct
9 Correct 124 ms 235160 KB Output is correct
10 Correct 129 ms 235368 KB Output is correct
11 Correct 129 ms 235448 KB Output is correct
12 Correct 123 ms 235192 KB Output is correct
13 Correct 130 ms 235696 KB Output is correct
14 Correct 133 ms 235720 KB Output is correct
15 Correct 134 ms 235432 KB Output is correct
16 Correct 141 ms 235356 KB Output is correct
17 Correct 130 ms 235416 KB Output is correct
18 Correct 127 ms 235268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 245 ms 262144 KB Execution killed with signal 9
2 Runtime error 187 ms 262144 KB Execution killed with signal 9
3 Runtime error 174 ms 262144 KB Execution killed with signal 9
4 Runtime error 172 ms 262144 KB Execution killed with signal 9
5 Runtime error 159 ms 262144 KB Execution killed with signal 9
6 Runtime error 162 ms 262144 KB Execution killed with signal 9
7 Runtime error 229 ms 262144 KB Execution killed with signal 9
8 Runtime error 189 ms 262144 KB Execution killed with signal 9
9 Runtime error 172 ms 262144 KB Execution killed with signal 9
10 Runtime error 141 ms 262144 KB Execution killed with signal 9
11 Runtime error 156 ms 262144 KB Execution killed with signal 9
12 Runtime error 158 ms 262144 KB Execution killed with signal 9
13 Runtime error 156 ms 262144 KB Execution killed with signal 9
14 Runtime error 152 ms 262144 KB Execution killed with signal 9
15 Runtime error 140 ms 262144 KB Execution killed with signal 9
16 Runtime error 183 ms 262144 KB Execution killed with signal 9
17 Runtime error 136 ms 262144 KB Execution killed with signal 9
18 Runtime error 178 ms 262144 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 157 ms 262144 KB Execution killed with signal 9
2 Runtime error 161 ms 262144 KB Execution killed with signal 9
3 Runtime error 151 ms 262144 KB Execution killed with signal 9
4 Runtime error 149 ms 262144 KB Execution killed with signal 9
5 Runtime error 288 ms 262144 KB Execution killed with signal 9
6 Runtime error 183 ms 262144 KB Execution killed with signal 9
7 Runtime error 189 ms 262144 KB Execution killed with signal 9
8 Runtime error 154 ms 262144 KB Execution killed with signal 9
9 Runtime error 184 ms 262144 KB Execution killed with signal 9
10 Runtime error 163 ms 262144 KB Execution killed with signal 9
11 Runtime error 144 ms 262144 KB Execution killed with signal 9
12 Runtime error 142 ms 262144 KB Execution killed with signal 9
13 Runtime error 179 ms 262144 KB Execution killed with signal 9
14 Runtime error 144 ms 262144 KB Execution killed with signal 9
15 Runtime error 149 ms 262144 KB Execution killed with signal 9
16 Runtime error 131 ms 262144 KB Execution killed with signal 9
17 Runtime error 175 ms 262144 KB Execution killed with signal 9
18 Runtime error 149 ms 262144 KB Execution killed with signal 9
19 Runtime error 149 ms 262144 KB Execution killed with signal 9
20 Runtime error 157 ms 262144 KB Execution killed with signal 9
21 Runtime error 166 ms 262144 KB Execution killed with signal 9
22 Runtime error 163 ms 262144 KB Execution killed with signal 9
23 Runtime error 268 ms 262144 KB Execution killed with signal 9
24 Runtime error 187 ms 262144 KB Execution killed with signal 9
25 Runtime error 171 ms 262144 KB Execution killed with signal 9
26 Runtime error 160 ms 262144 KB Execution killed with signal 9
27 Runtime error 142 ms 262144 KB Execution killed with signal 9
28 Runtime error 160 ms 262144 KB Execution killed with signal 9
29 Runtime error 170 ms 262144 KB Execution killed with signal 9
30 Runtime error 208 ms 262144 KB Execution killed with signal 9
31 Runtime error 151 ms 262144 KB Execution killed with signal 9
32 Runtime error 157 ms 262144 KB Execution killed with signal 9
33 Runtime error 193 ms 262144 KB Execution killed with signal 9
34 Runtime error 167 ms 262144 KB Execution killed with signal 9
35 Runtime error 152 ms 262144 KB Execution killed with signal 9
36 Runtime error 155 ms 262144 KB Execution killed with signal 9
37 Runtime error 258 ms 262144 KB Execution killed with signal 9
38 Runtime error 148 ms 262144 KB Execution killed with signal 9
39 Runtime error 177 ms 262144 KB Execution killed with signal 9
40 Runtime error 174 ms 262144 KB Execution killed with signal 9
41 Runtime error 156 ms 262144 KB Execution killed with signal 9
42 Runtime error 146 ms 262144 KB Execution killed with signal 9