Submission #553603

# Submission time Handle Problem Language Result Execution time Memory
553603 2022-04-26T10:48:23 Z new_acc Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
244 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<int> curr;
	curr.push_back(0);
	ile[0]=m;
	for(int i=1;i<=maxi;i++){
		for(auto u:dziel[i]) ile[((i/u)-1)*u]--;
		while(curr.size() and !ile[curr[0]]) curr.pop_front();
		if(!curr.size()) dp[i]=INFi;
		else dp[i]=min(dp[curr[0]]+1,INFi);
		curr.push_back(i);
		ile[i]=dziel[i].size();
	}
	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 129 ms 235212 KB Output is correct
2 Correct 121 ms 235384 KB Output is correct
3 Correct 114 ms 235340 KB Output is correct
4 Correct 120 ms 235340 KB Output is correct
5 Correct 116 ms 235168 KB Output is correct
6 Correct 114 ms 235388 KB Output is correct
7 Correct 112 ms 235396 KB Output is correct
8 Correct 113 ms 235408 KB Output is correct
9 Correct 122 ms 235132 KB Output is correct
10 Correct 107 ms 235396 KB Output is correct
11 Correct 120 ms 235436 KB Output is correct
12 Correct 113 ms 235144 KB Output is correct
13 Correct 117 ms 235660 KB Output is correct
14 Correct 131 ms 235592 KB Output is correct
15 Correct 140 ms 235340 KB Output is correct
16 Correct 124 ms 235380 KB Output is correct
17 Correct 122 ms 235332 KB Output is correct
18 Correct 116 ms 235296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 221 ms 262144 KB Execution killed with signal 9
2 Runtime error 185 ms 262144 KB Execution killed with signal 9
3 Runtime error 138 ms 262144 KB Execution killed with signal 9
4 Runtime error 130 ms 262144 KB Execution killed with signal 9
5 Runtime error 128 ms 262144 KB Execution killed with signal 9
6 Runtime error 142 ms 262144 KB Execution killed with signal 9
7 Runtime error 200 ms 262144 KB Execution killed with signal 9
8 Runtime error 160 ms 262144 KB Execution killed with signal 9
9 Runtime error 130 ms 262144 KB Execution killed with signal 9
10 Runtime error 128 ms 262144 KB Execution killed with signal 9
11 Runtime error 127 ms 262144 KB Execution killed with signal 9
12 Runtime error 146 ms 262144 KB Execution killed with signal 9
13 Runtime error 134 ms 262144 KB Execution killed with signal 9
14 Runtime error 137 ms 262144 KB Execution killed with signal 9
15 Runtime error 153 ms 262144 KB Execution killed with signal 9
16 Runtime error 167 ms 262144 KB Execution killed with signal 9
17 Runtime error 121 ms 262144 KB Execution killed with signal 9
18 Runtime error 133 ms 262144 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 262144 KB Execution killed with signal 9
2 Runtime error 129 ms 262144 KB Execution killed with signal 9
3 Runtime error 142 ms 262144 KB Execution killed with signal 9
4 Runtime error 136 ms 262144 KB Execution killed with signal 9
5 Runtime error 237 ms 262144 KB Execution killed with signal 9
6 Runtime error 132 ms 262144 KB Execution killed with signal 9
7 Runtime error 165 ms 262144 KB Execution killed with signal 9
8 Runtime error 129 ms 262144 KB Execution killed with signal 9
9 Runtime error 129 ms 262144 KB Execution killed with signal 9
10 Runtime error 135 ms 262144 KB Execution killed with signal 9
11 Runtime error 140 ms 262144 KB Execution killed with signal 9
12 Runtime error 124 ms 262144 KB Execution killed with signal 9
13 Runtime error 142 ms 262144 KB Execution killed with signal 9
14 Runtime error 135 ms 262144 KB Execution killed with signal 9
15 Runtime error 123 ms 262144 KB Execution killed with signal 9
16 Runtime error 134 ms 262144 KB Execution killed with signal 9
17 Runtime error 156 ms 262144 KB Execution killed with signal 9
18 Runtime error 133 ms 262144 KB Execution killed with signal 9
19 Runtime error 121 ms 262144 KB Execution killed with signal 9
20 Runtime error 148 ms 262144 KB Execution killed with signal 9
21 Runtime error 136 ms 262144 KB Execution killed with signal 9
22 Runtime error 141 ms 262144 KB Execution killed with signal 9
23 Runtime error 237 ms 262144 KB Execution killed with signal 9
24 Runtime error 157 ms 262144 KB Execution killed with signal 9
25 Runtime error 132 ms 262144 KB Execution killed with signal 9
26 Runtime error 143 ms 262144 KB Execution killed with signal 9
27 Runtime error 141 ms 262144 KB Execution killed with signal 9
28 Runtime error 135 ms 262144 KB Execution killed with signal 9
29 Runtime error 146 ms 262144 KB Execution killed with signal 9
30 Runtime error 157 ms 262144 KB Execution killed with signal 9
31 Runtime error 139 ms 262144 KB Execution killed with signal 9
32 Runtime error 130 ms 262144 KB Execution killed with signal 9
33 Runtime error 178 ms 262144 KB Execution killed with signal 9
34 Runtime error 166 ms 262144 KB Execution killed with signal 9
35 Runtime error 136 ms 262144 KB Execution killed with signal 9
36 Runtime error 138 ms 262144 KB Execution killed with signal 9
37 Runtime error 244 ms 262144 KB Execution killed with signal 9
38 Runtime error 131 ms 262144 KB Execution killed with signal 9
39 Runtime error 157 ms 262144 KB Execution killed with signal 9
40 Runtime error 132 ms 262144 KB Execution killed with signal 9
41 Runtime error 136 ms 262144 KB Execution killed with signal 9
42 Runtime error 134 ms 262144 KB Execution killed with signal 9