Submission #925359

# Submission time Handle Problem Language Result Execution time Memory
925359 2024-02-11T13:36:36 Z 8pete8 Brunhilda’s Birthday (BOI13_brunhilda) C++17
0 / 100
149 ms 262144 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<cassert>
#include<limits.h>
#include<cmath>
#include<set>
#include<numeric> //gcd(a,b)
#include<algorithm>
#include<bitset> 
#include<stack>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define pppiiii pair<pii,pii>
#define ppii pair<int,pii>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
//#define int long long
const int mod=1e9+7,mxn=1e8+5,lg=30;//inf=1e18,minf=-1e18,Mxn=100000,root=700;
void setIO(string name){		
	ios_base::sync_with_stdio(0); cin.tie(0);		
	freopen((name+".in").c_str(),"r",stdin);		
	freopen((name+".out").c_str(),"w",stdout);	
}	
int n,q;
int ans[mxn+10],mx[mxn+10];
int32_t main(){
	//setIO("redistricting");
	fastio
	cin>>n>>q;
	vector<int>v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	sort(all(v));
	v.erase(unique(all(v)),v.end());
	for(auto i:v)for(int j=i-1;j<=mxn;j+=i)mx[j]=max(mx[j],i-1);
	for(int i=mxn;i>=0;i--)mx[i]=max(mx[i],mx[i+1]-1);
	for(int i=1;i<=mxn;i++)ans[i]=ans[i-mx[i]]+1;
	while(q--){
		int g;cin>>g;
		if(mx[g])cout<<ans[g]<<'\n';
		else cout<<"oo"<<'\n';
	}
}

Compilation message

brunhilda.cpp: In function 'void setIO(std::string)':
brunhilda.cpp:37:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
brunhilda.cpp:38:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 114 ms 262144 KB Execution killed with signal 9
2 Runtime error 128 ms 262144 KB Execution killed with signal 9
3 Runtime error 121 ms 262144 KB Execution killed with signal 9
4 Runtime error 96 ms 262144 KB Execution killed with signal 9
5 Runtime error 106 ms 262144 KB Execution killed with signal 9
6 Runtime error 98 ms 262144 KB Execution killed with signal 9
7 Runtime error 119 ms 262144 KB Execution killed with signal 9
8 Runtime error 121 ms 262144 KB Execution killed with signal 9
9 Runtime error 129 ms 262144 KB Execution killed with signal 9
10 Runtime error 122 ms 262144 KB Execution killed with signal 9
11 Runtime error 113 ms 262144 KB Execution killed with signal 9
12 Runtime error 97 ms 262144 KB Execution killed with signal 9
13 Runtime error 121 ms 262144 KB Execution killed with signal 9
14 Runtime error 120 ms 262144 KB Execution killed with signal 9
15 Runtime error 124 ms 262144 KB Execution killed with signal 9
16 Runtime error 120 ms 262144 KB Execution killed with signal 9
17 Runtime error 98 ms 262144 KB Execution killed with signal 9
18 Runtime error 94 ms 262144 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 95 ms 262144 KB Execution killed with signal 9
2 Runtime error 109 ms 262144 KB Execution killed with signal 9
3 Runtime error 126 ms 262144 KB Execution killed with signal 9
4 Runtime error 104 ms 262144 KB Execution killed with signal 9
5 Runtime error 116 ms 262144 KB Execution killed with signal 9
6 Runtime error 121 ms 262144 KB Execution killed with signal 9
7 Runtime error 97 ms 262144 KB Execution killed with signal 9
8 Runtime error 101 ms 262144 KB Execution killed with signal 9
9 Runtime error 119 ms 262144 KB Execution killed with signal 9
10 Runtime error 149 ms 262144 KB Execution killed with signal 9
11 Runtime error 124 ms 262144 KB Execution killed with signal 9
12 Runtime error 128 ms 262144 KB Execution killed with signal 9
13 Runtime error 103 ms 262144 KB Execution killed with signal 9
14 Runtime error 103 ms 262144 KB Execution killed with signal 9
15 Runtime error 123 ms 262144 KB Execution killed with signal 9
16 Runtime error 115 ms 262144 KB Execution killed with signal 9
17 Runtime error 120 ms 262144 KB Execution killed with signal 9
18 Runtime error 120 ms 262144 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 134 ms 262144 KB Execution killed with signal 9
2 Runtime error 126 ms 262144 KB Execution killed with signal 9
3 Runtime error 132 ms 262144 KB Execution killed with signal 9
4 Runtime error 120 ms 262144 KB Execution killed with signal 9
5 Runtime error 109 ms 262144 KB Execution killed with signal 9
6 Runtime error 126 ms 262144 KB Execution killed with signal 9
7 Runtime error 117 ms 262144 KB Execution killed with signal 9
8 Runtime error 127 ms 262144 KB Execution killed with signal 9
9 Runtime error 125 ms 262144 KB Execution killed with signal 9
10 Runtime error 112 ms 262144 KB Execution killed with signal 9
11 Runtime error 107 ms 262144 KB Execution killed with signal 9
12 Runtime error 123 ms 262144 KB Execution killed with signal 9
13 Runtime error 122 ms 262144 KB Execution killed with signal 9
14 Runtime error 121 ms 262144 KB Execution killed with signal 9
15 Runtime error 128 ms 262144 KB Execution killed with signal 9
16 Runtime error 133 ms 262144 KB Execution killed with signal 9
17 Runtime error 120 ms 262144 KB Execution killed with signal 9
18 Runtime error 136 ms 262144 KB Execution killed with signal 9
19 Runtime error 113 ms 262144 KB Execution killed with signal 9
20 Runtime error 130 ms 262144 KB Execution killed with signal 9
21 Runtime error 122 ms 262144 KB Execution killed with signal 9
22 Runtime error 135 ms 262144 KB Execution killed with signal 9
23 Runtime error 99 ms 262144 KB Execution killed with signal 9
24 Runtime error 101 ms 262144 KB Execution killed with signal 9
25 Runtime error 112 ms 262144 KB Execution killed with signal 9
26 Runtime error 121 ms 262144 KB Execution killed with signal 9
27 Runtime error 135 ms 262144 KB Execution killed with signal 9
28 Runtime error 107 ms 262144 KB Execution killed with signal 9
29 Runtime error 116 ms 262144 KB Execution killed with signal 9
30 Runtime error 104 ms 262144 KB Execution killed with signal 9
31 Runtime error 106 ms 262144 KB Execution killed with signal 9
32 Runtime error 110 ms 262144 KB Execution killed with signal 9
33 Runtime error 106 ms 262144 KB Execution killed with signal 9
34 Runtime error 112 ms 262144 KB Execution killed with signal 9
35 Runtime error 112 ms 262144 KB Execution killed with signal 9
36 Runtime error 139 ms 262144 KB Execution killed with signal 9
37 Runtime error 109 ms 262144 KB Execution killed with signal 9
38 Runtime error 123 ms 262144 KB Execution killed with signal 9
39 Runtime error 104 ms 262144 KB Execution killed with signal 9
40 Runtime error 124 ms 262144 KB Execution killed with signal 9
41 Runtime error 129 ms 262144 KB Execution killed with signal 9
42 Runtime error 124 ms 262144 KB Execution killed with signal 9