Submission #129954

# Submission time Handle Problem Language Result Execution time Memory
129954 2019-07-13T15:53:22 Z MohamedAhmed04 Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
1000 ms 1664 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1e4 + 5 ;
const int OO = 1e9 ;

int dp[MAX] ;

int main()
{
	int n , q ;
	scanf("%d %d" , &n , &q) ;
	int arr[n] ;
	for(int i = 0 ; i < n ; ++i)
		scanf("%d" , &arr[i]) ;
	dp[0] = 0 ;
	for(int i = 1 ; i < MAX ; ++i)
	{
		dp[i] = OO ; 
		for(int j = 0 ; j < n ; ++j)
		{
			if(i % arr[j] == 0)
				continue ;
			dp[i] = min(dp[i] , dp[i - (i % arr[j])] + 1) ;
		}
	}
	while(q--)
	{
		int x ;
		scanf("%d" , &x) ;
		if(dp[x] >= OO)
			cout<<"oo\n" ;
		else
			cout<<dp[x]<<"\n";
	}
	return 0 ;
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:13: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:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &arr[i]) ;
   ~~~~~^~~~~~~~~~~~~~~~
brunhilda.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &x) ;
   ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 9 ms 376 KB Output is 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 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 8 ms 376 KB Output is correct
13 Correct 60 ms 416 KB Output is correct
14 Correct 63 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 7 ms 504 KB Output is correct
18 Correct 9 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 698 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Execution timed out 1067 ms 1500 KB Time limit exceeded
3 Execution timed out 1089 ms 1156 KB Time limit exceeded
4 Runtime error 184 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Execution timed out 1086 ms 980 KB Time limit exceeded
6 Runtime error 72 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 695 ms 740 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 61 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Execution timed out 1081 ms 1272 KB Time limit exceeded
10 Execution timed out 1084 ms 1144 KB Time limit exceeded
11 Execution timed out 1086 ms 1016 KB Time limit exceeded
12 Runtime error 127 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 173 ms 604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 182 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Execution timed out 1084 ms 928 KB Time limit exceeded
16 Execution timed out 1085 ms 1528 KB Time limit exceeded
17 Runtime error 179 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Execution timed out 1080 ms 1592 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 1176 KB Time limit exceeded
2 Execution timed out 1083 ms 1144 KB Time limit exceeded
3 Execution timed out 1078 ms 1272 KB Time limit exceeded
4 Runtime error 200 ms 776 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Execution timed out 1076 ms 1632 KB Time limit exceeded
6 Runtime error 469 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Execution timed out 1067 ms 1660 KB Time limit exceeded
8 Execution timed out 1076 ms 1152 KB Time limit exceeded
9 Execution timed out 1075 ms 1272 KB Time limit exceeded
10 Runtime error 342 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 260 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 349 ms 736 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Execution timed out 1081 ms 888 KB Time limit exceeded
14 Runtime error 5 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 319 ms 892 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 411 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Execution timed out 1082 ms 1088 KB Time limit exceeded
18 Execution timed out 1086 ms 1196 KB Time limit exceeded
19 Runtime error 297 ms 644 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Execution timed out 1082 ms 1016 KB Time limit exceeded
21 Runtime error 9 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Execution timed out 1076 ms 1664 KB Time limit exceeded
23 Execution timed out 1084 ms 972 KB Time limit exceeded
24 Runtime error 68 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 172 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 198 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Execution timed out 1081 ms 1656 KB Time limit exceeded
28 Runtime error 62 ms 576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Execution timed out 1078 ms 1656 KB Time limit exceeded
30 Execution timed out 1064 ms 1400 KB Time limit exceeded
31 Runtime error 254 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 170 ms 772 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 73 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Execution timed out 1079 ms 1528 KB Time limit exceeded
35 Runtime error 118 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Execution timed out 1085 ms 1528 KB Time limit exceeded
37 Execution timed out 1075 ms 1624 KB Time limit exceeded
38 Runtime error 469 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 134 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 546 ms 904 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Execution timed out 1076 ms 1660 KB Time limit exceeded
42 Runtime error 178 ms 752 KB Execution killed with signal 11 (could be triggered by violating memory limits)