Submission #320037

# Submission time Handle Problem Language Result Execution time Memory
320037 2020-11-07T10:59:38 Z Hemimor Brunhilda’s Birthday (BOI13_brunhilda) C++14
0 / 100
171 ms 262148 KB
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=10000001;
int n,q,res[M];
vi a;

int main(){
	scanf("%d%d",&n,&q);
	a=vi(n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	int mx=a[n-1];
	fill(res,res+mx,1);
	fill(res+mx,res+M,inf);
	multiset<int> st;
	priority_queue<P,vector<P>,greater<P>> que;
	vvi b(M);
	for(auto i:a){
		st.insert(1);
		que.push({(mx+i-1)/i*i,i});
	}
	for(int i=mx;i<M;i++){
		int t=0;
		while(que.top().first==i){
			int j=que.top().second,x=res[i-j];
			que.pop();
			st.erase(st.find(x));
			que.push({i+j,j});
			t++;
		}
		if(!st.empty()) res[i]=min(inf,1+*st.begin());
		while(t){
			st.insert(res[i]);
			t--;
		}
	}
	for(int i=0;i<q;i++){
		int x;
		scanf("%d",&x);
		if(res[x]==inf) printf("oo\n");
		else printf("%d\n",res[x]);
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |  scanf("%d%d",&n,&q);
      |  ~~~~~^~~~~~~~~~~~~~
brunhilda.cpp:45:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |  for(int i=0;i<n;i++) scanf("%d",&a[i]);
      |                       ~~~~~^~~~~~~~~~~~
brunhilda.cpp:73:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   73 |   scanf("%d",&x);
      |   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 142 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 142 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 142 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 167 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 154 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 140 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 145 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 144 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 141 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 141 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 140 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 141 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 140 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 160 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 145 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 146 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 164 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 144 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 144 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 161 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 171 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 144 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 142 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 144 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 147 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 140 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 163 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 151 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 149 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 143 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 144 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 138 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 149 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 162 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 139 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 160 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 146 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 155 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 147 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 144 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 159 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 144 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 153 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 147 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 152 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 140 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 143 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 148 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 153 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 140 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 144 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 147 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 146 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 149 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 143 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 150 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
21 Runtime error 143 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
22 Runtime error 151 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
23 Runtime error 145 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
24 Runtime error 149 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
25 Runtime error 142 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
26 Runtime error 145 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
27 Runtime error 169 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
28 Runtime error 142 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
29 Runtime error 154 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
30 Runtime error 152 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
31 Runtime error 139 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
32 Runtime error 143 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
33 Runtime error 141 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
34 Runtime error 157 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
35 Runtime error 142 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
36 Runtime error 153 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
37 Runtime error 154 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
38 Runtime error 141 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Runtime error 155 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
40 Runtime error 157 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
41 Runtime error 155 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
42 Runtime error 140 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)