답안 #334270

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334270 2020-12-08T22:29:20 Z Fischer Brunhilda’s Birthday (BOI13_brunhilda) C++14
63.6508 / 100
1000 ms 262148 KB
#include <bits/stdc++.h>
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define reo(x, y) for (int x = 0; x < y; ++x)
using namespace std;
 
const int maxn = 1e7 + 10;
int head[maxn];
int val[2 * maxn];
int nxt[2 * maxn];
int T = 0;
int cnt[maxn];
int dp[maxn];
int p[100010];
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int m, q;
	cin >> m >> q;
	memset(head, -1, sizeof head);
	for (int i = 0; i < m; ++i) {
		cin >> p[i];
		for (int j=p[i]; j<maxn; j+=p[i]) {
			assert(T < 2 * maxn);
			nxt[T] = head[j];
			head[j] = T;
			val[T] = j - p[i];
			T++;
		}
	}
	int front = 0;
	cnt[0] = m;
	const int mx = 1e9;
	for (int i = 1; i < maxn; ++i) {
		for (int x = head[i]; ~x; x = nxt[x]) {
			cnt[i]++;
			cnt[val[x]]--;
		}
		while (front < i && cnt[front] == 0) front++;
		if (front == i) dp[i] = mx;
		else dp[i] = min(mx, dp[front] + 1);
	}
	while (q--) {
		int n;
		cin >> n;
		if (dp[n] > n) cout << "oo\n";
		else cout << dp[n] << '\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 131948 KB Output is correct
2 Correct 252 ms 198380 KB Output is correct
3 Correct 204 ms 178284 KB Output is correct
4 Correct 139 ms 123756 KB Output is correct
5 Correct 191 ms 141036 KB Output is correct
6 Correct 157 ms 131820 KB Output is correct
7 Correct 206 ms 178284 KB Output is correct
8 Correct 241 ms 204908 KB Output is correct
9 Correct 318 ms 228332 KB Output is correct
10 Correct 366 ms 240620 KB Output is correct
11 Correct 318 ms 203116 KB Output is correct
12 Correct 125 ms 122092 KB Output is correct
13 Runtime error 517 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
14 Runtime error 511 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
15 Correct 277 ms 195948 KB Output is correct
16 Correct 257 ms 198380 KB Output is correct
17 Correct 215 ms 141420 KB Output is correct
18 Correct 133 ms 123756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 256 ms 131436 KB Output is correct
2 Correct 264 ms 136812 KB Output is correct
3 Runtime error 517 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
4 Correct 321 ms 156268 KB Output is correct
5 Correct 739 ms 229228 KB Output is correct
6 Correct 237 ms 174060 KB Output is correct
7 Correct 235 ms 131584 KB Output is correct
8 Correct 285 ms 152044 KB Output is correct
9 Correct 963 ms 245868 KB Output is correct
10 Runtime error 532 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
11 Runtime error 536 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
12 Correct 471 ms 214608 KB Output is correct
13 Correct 177 ms 138732 KB Output is correct
14 Correct 316 ms 156268 KB Output is correct
15 Runtime error 567 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
16 Correct 259 ms 136812 KB Output is correct
17 Runtime error 538 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
18 Correct 941 ms 257516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 551 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Runtime error 531 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
3 Runtime error 527 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
4 Correct 524 ms 225208 KB Output is correct
5 Correct 368 ms 137068 KB Output is correct
6 Runtime error 755 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Correct 732 ms 196332 KB Output is correct
8 Runtime error 522 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
9 Runtime error 526 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
10 Correct 673 ms 208492 KB Output is correct
11 Correct 507 ms 185068 KB Output is correct
12 Runtime error 722 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 575 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
14 Correct 427 ms 250600 KB Output is correct
15 Runtime error 525 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
16 Runtime error 517 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
17 Correct 895 ms 236648 KB Output is correct
18 Runtime error 527 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
19 Correct 220 ms 154476 KB Output is correct
20 Runtime error 534 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
21 Runtime error 469 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
22 Runtime error 548 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
23 Correct 424 ms 140012 KB Output is correct
24 Correct 213 ms 133484 KB Output is correct
25 Correct 619 ms 223624 KB Output is correct
26 Correct 533 ms 224892 KB Output is correct
27 Runtime error 539 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
28 Correct 230 ms 149996 KB Output is correct
29 Execution timed out 1115 ms 236068 KB Time limit exceeded
30 Execution timed out 1045 ms 215052 KB Time limit exceeded
31 Correct 317 ms 153836 KB Output is correct
32 Correct 378 ms 165892 KB Output is correct
33 Correct 182 ms 126656 KB Output is correct
34 Correct 746 ms 196200 KB Output is correct
35 Correct 272 ms 152044 KB Output is correct
36 Runtime error 550 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
37 Correct 380 ms 137060 KB Output is correct
38 Runtime error 738 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Correct 269 ms 138348 KB Output is correct
40 Correct 715 ms 243952 KB Output is correct
41 Correct 655 ms 217324 KB Output is correct
42 Runtime error 528 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)