Submission #553581

# Submission time Handle Problem Language Result Execution time Memory
553581 2022-04-26T09:45:58 Z new_acc Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
95 ms 82892 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];
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 12 ms 23892 KB Output is correct
2 Correct 14 ms 24020 KB Output is correct
3 Correct 13 ms 24020 KB Output is correct
4 Correct 14 ms 23952 KB Output is correct
5 Correct 13 ms 23764 KB Output is correct
6 Correct 13 ms 23892 KB Output is correct
7 Correct 13 ms 24020 KB Output is correct
8 Correct 13 ms 24020 KB Output is correct
9 Correct 14 ms 23812 KB Output is correct
10 Correct 15 ms 24020 KB Output is correct
11 Correct 14 ms 24024 KB Output is correct
12 Correct 12 ms 23860 KB Output is correct
13 Correct 15 ms 24396 KB Output is correct
14 Correct 17 ms 24472 KB Output is correct
15 Correct 16 ms 24020 KB Output is correct
16 Correct 14 ms 24040 KB Output is correct
17 Correct 16 ms 24080 KB Output is correct
18 Correct 15 ms 24020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 48840 KB Execution killed with signal 11
2 Runtime error 46 ms 51120 KB Execution killed with signal 11
3 Runtime error 75 ms 80756 KB Execution killed with signal 11
4 Runtime error 41 ms 57164 KB Execution killed with signal 11
5 Runtime error 69 ms 69964 KB Execution killed with signal 11
6 Runtime error 67 ms 79820 KB Execution killed with signal 11
7 Runtime error 34 ms 48848 KB Execution killed with signal 11
8 Runtime error 41 ms 53900 KB Execution killed with signal 11
9 Runtime error 64 ms 70220 KB Execution killed with signal 11
10 Runtime error 82 ms 80760 KB Execution killed with signal 11
11 Runtime error 74 ms 80392 KB Execution killed with signal 11
12 Runtime error 67 ms 79756 KB Execution killed with signal 11
13 Runtime error 40 ms 57164 KB Execution killed with signal 11
14 Runtime error 47 ms 57212 KB Execution killed with signal 11
15 Runtime error 72 ms 80352 KB Execution killed with signal 11
16 Runtime error 48 ms 51188 KB Execution killed with signal 11
17 Runtime error 68 ms 79868 KB Execution killed with signal 11
18 Runtime error 67 ms 70740 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 73 ms 81228 KB Execution killed with signal 11
2 Runtime error 77 ms 80912 KB Execution killed with signal 11
3 Runtime error 91 ms 81404 KB Execution killed with signal 11
4 Runtime error 70 ms 81228 KB Execution killed with signal 11
5 Runtime error 52 ms 51236 KB Execution killed with signal 11
6 Runtime error 77 ms 81344 KB Execution killed with signal 11
7 Runtime error 50 ms 54220 KB Execution killed with signal 11
8 Runtime error 95 ms 81140 KB Execution killed with signal 11
9 Runtime error 82 ms 81164 KB Execution killed with signal 11
10 Runtime error 50 ms 61036 KB Execution killed with signal 11
11 Runtime error 50 ms 61160 KB Execution killed with signal 11
12 Runtime error 72 ms 80140 KB Execution killed with signal 11
13 Runtime error 75 ms 81612 KB Execution killed with signal 11
14 Runtime error 69 ms 81256 KB Execution killed with signal 11
15 Runtime error 68 ms 80272 KB Execution killed with signal 11
16 Runtime error 76 ms 80204 KB Execution killed with signal 11
17 Runtime error 71 ms 69964 KB Execution killed with signal 11
18 Runtime error 66 ms 80948 KB Execution killed with signal 11
19 Runtime error 58 ms 69624 KB Execution killed with signal 11
20 Runtime error 76 ms 81344 KB Execution killed with signal 11
21 Runtime error 77 ms 81292 KB Execution killed with signal 11
22 Runtime error 77 ms 82892 KB Execution killed with signal 11
23 Runtime error 43 ms 50052 KB Execution killed with signal 11
24 Runtime error 44 ms 52904 KB Execution killed with signal 11
25 Runtime error 68 ms 70780 KB Execution killed with signal 11
26 Runtime error 77 ms 81192 KB Execution killed with signal 11
27 Runtime error 76 ms 82056 KB Execution killed with signal 11
28 Runtime error 57 ms 62300 KB Execution killed with signal 11
29 Runtime error 55 ms 56004 KB Execution killed with signal 11
30 Runtime error 65 ms 52840 KB Execution killed with signal 11
31 Runtime error 51 ms 58508 KB Execution killed with signal 11
32 Runtime error 52 ms 62212 KB Execution killed with signal 11
33 Runtime error 44 ms 52812 KB Execution killed with signal 11
34 Runtime error 54 ms 54116 KB Execution killed with signal 11
35 Runtime error 66 ms 62384 KB Execution killed with signal 11
36 Runtime error 89 ms 82688 KB Execution killed with signal 11
37 Runtime error 50 ms 51220 KB Execution killed with signal 11
38 Runtime error 68 ms 81268 KB Execution killed with signal 11
39 Runtime error 45 ms 52936 KB Execution killed with signal 11
40 Runtime error 76 ms 81348 KB Execution killed with signal 11
41 Runtime error 80 ms 82216 KB Execution killed with signal 11
42 Runtime error 74 ms 81424 KB Execution killed with signal 11