Submission #318083

# Submission time Handle Problem Language Result Execution time Memory
318083 2020-10-31T12:28:29 Z shivensinha4 Brunhilda’s Birthday (BOI13_brunhilda) C++17
0 / 100
285 ms 262148 KB
#include "bits/stdc++.h"
using namespace std; 
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'
 
const int MXV = 1e7;
int ans[MXV+2];
vi fac[MXV+2];
 
int main() {
	#ifdef shiven
	freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int m, q; cin >> m >> q;
	int mxp = -1;
	for_(i, 0, m)  {
		int p; cin >> p;
		fac[p].push_back(p);
		mxp = max(mxp, p);
	}
	
	deque<ii> last; // {val, nxt}
	last.push_back({0, mxp});
	int pt = 0;
	for_(i, 1, MXV+1) {
		if (last.size() and last.front().second == i) last.pop_front();
		if (last.size()) ans[i] = ans[last.front().first]+1;
		
		for (int f = fac[i].size()-1; f >= 0; f--) {
			int nxt = i+fac[i][f];
			if (ans[i] and last.back().second < nxt) last.push_back({i, nxt});
			if (nxt <= MXV) fac[nxt].push_back(fac[i][f]);
			fac[i].pop_back();
		}
	}
	
	for_(i, 0, q) {
		int k; cin >> k;
		assert(k <= MXV);
		if (!ans[k]) cout << "oo";
		else cout << ans[k];
		cout << endl;
	}
	
 
	return 0;
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:32:6: warning: unused variable 'pt' [-Wunused-variable]
   32 |  int pt = 0;
      |      ^~
# Verdict Execution time Memory Grader output
1 Runtime error 210 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 198 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 188 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 191 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 195 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 204 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 196 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 196 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 210 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 223 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 209 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 194 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 252 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 244 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 204 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 203 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 212 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 204 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 226 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 239 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 276 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 210 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 241 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 194 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 226 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 206 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 252 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 284 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 275 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 217 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 199 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 212 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 268 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 240 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 259 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 263 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 274 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 279 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 226 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 249 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 250 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 243 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 265 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 266 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 223 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 215 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 246 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 274 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 224 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 251 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 254 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 280 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 197 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 278 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
21 Runtime error 229 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
22 Runtime error 276 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
23 Runtime error 240 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
24 Runtime error 203 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
25 Runtime error 224 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
26 Runtime error 223 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
27 Runtime error 285 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
28 Runtime error 210 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
29 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
30 Runtime error 238 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
31 Runtime error 210 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
32 Runtime error 209 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
33 Runtime error 202 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
34 Runtime error 242 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
35 Runtime error 207 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
36 Runtime error 274 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
37 Runtime error 254 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
38 Runtime error 254 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Runtime error 210 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
40 Runtime error 240 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
41 Runtime error 246 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
42 Runtime error 254 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)