Submission #134076

# Submission time Handle Problem Language Result Execution time Memory
134076 2019-07-22T03:59:51 Z wilwxk Brunhilda’s Birthday (BOI13_brunhilda) C++14
11.1111 / 100
17 ms 2268 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN=1e5+5;
const int MAXX=1e4+3;
const int INF=1e9;
int v[MAXN];
int dp[MAXX];
int n, q;

int main() {
	scanf("%d %d", &n, &q);
	for(int i=0; i<n; i++) scanf("%d", &v[i]);
	dp[0]=0;
	for(int i=1; i<v[n-1]; i++) dp[i]=1; 
	for(int i=v[n-1]; i<MAXX; i++) {
		dp[i]=INF;
		bool ok=0;
		for(int j=n-1; j>=0; j--) {
			if(i%v[j]==0) continue;
			if(v[j]*v[j]>MAXN) break;
			int ind=i-(i%v[j]);
			dp[i]=min(dp[i], dp[ind]+1);
		}
	}

	// for(int i=0; i<MAXX; i++) printf("%d ", dp[i]);
	while(q--) {
		int a; scanf("%d", &a);
		if(dp[a]==-1||dp[a]>MAXN) printf("oo\n");
		else printf("%d\n", dp[a]);
	}

}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:18:8: warning: unused variable 'ok' [-Wunused-variable]
   bool ok=0;
        ^~
brunhilda.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~~
brunhilda.cpp:13:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<n; i++) scanf("%d", &v[i]);
                         ~~~~~^~~~~~~~~~~~~
brunhilda.cpp:29:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a; scanf("%d", &a);
          ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 4 ms 376 KB Output isn't correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 3 ms 380 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Incorrect 3 ms 376 KB Output isn't correct
14 Incorrect 4 ms 504 KB Output isn't correct
15 Incorrect 2 ms 376 KB Output isn't correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Incorrect 4 ms 376 KB Output isn't correct
18 Incorrect 4 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 16 ms 2040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 12 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 4 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 10 ms 1720 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 3 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 5 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 4 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 13 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 12 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 9 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 4 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 4 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 10 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 17 ms 2040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 4 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 17 ms 2040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 10 ms 1816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 10 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 4 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 17 ms 2216 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 5 ms 1500 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 17 ms 2268 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 10 ms 1768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 10 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 5 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 4 ms 1448 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 5 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 8 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 5 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 4 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 4 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 10 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 10 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 4 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 10 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 17 ms 2228 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 8 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 3 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 3 ms 1004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 4 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 16 ms 2168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 4 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 17 ms 2196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 12 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 4 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 3 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 3 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 17 ms 2168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 4 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 15 ms 2168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 17 ms 2168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 4 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 4 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 4 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 17 ms 2168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 3 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)