답안 #134018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134018 2019-07-21T23:20:18 Z CaroLinda Brunhilda’s Birthday (BOI13_brunhilda) C++14
57.1429 / 100
1000 ms 40824 KB
#include <bits/stdc++.h>

#define lp(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back

const int MAXM = 1e5+10 ;
const int MAX = 1e7+10 ;

using namespace std ;

int v[MAXM] , dp[MAX] ;
int m , q ;

int solve(int x)
{
	if(x <= 0) return 0 ;
	if(dp[x] != -1) return dp[x] ;
	int maior = 0 ;
	lp(i,0,m) maior = max(maior, x%v[i] ) ;
	if(maior==0) return -2 ;
	int k = solve(x-maior) ;
	if(k == -2) return dp[x] = k ;
	return dp[x] = k+1 ;
}

int main()
{
	memset(dp,-1,sizeof dp) ;

	scanf("%d%d", &m, &q) ;
	lp(i,0,m) scanf("%d", &v[i]) ;
	lp(i,0,q)
	{
		int x ;
		scanf("%d", &x ) ;
		int ans = solve(x) ;
		if(ans==-2) printf("oo\n") ;
		else printf("%d\n", ans ) ;
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &m, &q) ;
  ~~~~~^~~~~~~~~~~~~~~~
brunhilda.cpp:34:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  lp(i,0,m) scanf("%d", &v[i]) ;
            ~~~~~^~~~~~~~~~~~~
brunhilda.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x ) ;
   ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 39416 KB Output is correct
2 Correct 35 ms 39544 KB Output is correct
3 Correct 41 ms 39416 KB Output is correct
4 Correct 47 ms 39516 KB Output is correct
5 Correct 42 ms 39416 KB Output is correct
6 Correct 34 ms 39416 KB Output is correct
7 Correct 34 ms 39416 KB Output is correct
8 Correct 34 ms 39544 KB Output is correct
9 Correct 34 ms 39416 KB Output is correct
10 Correct 34 ms 39416 KB Output is correct
11 Correct 34 ms 39416 KB Output is correct
12 Correct 34 ms 39416 KB Output is correct
13 Correct 38 ms 39416 KB Output is correct
14 Correct 69 ms 39548 KB Output is correct
15 Correct 34 ms 39464 KB Output is correct
16 Correct 35 ms 39416 KB Output is correct
17 Correct 39 ms 39520 KB Output is correct
18 Correct 39 ms 39516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 39544 KB Output is correct
2 Correct 51 ms 39988 KB Output is correct
3 Correct 45 ms 39732 KB Output is correct
4 Correct 39 ms 39544 KB Output is correct
5 Correct 42 ms 39672 KB Output is correct
6 Correct 35 ms 39460 KB Output is correct
7 Correct 36 ms 39548 KB Output is correct
8 Correct 35 ms 39544 KB Output is correct
9 Correct 45 ms 39800 KB Output is correct
10 Correct 44 ms 39712 KB Output is correct
11 Correct 42 ms 39672 KB Output is correct
12 Correct 36 ms 39416 KB Output is correct
13 Correct 34 ms 39404 KB Output is correct
14 Correct 36 ms 39544 KB Output is correct
15 Correct 43 ms 39692 KB Output is correct
16 Correct 48 ms 39928 KB Output is correct
17 Correct 38 ms 39416 KB Output is correct
18 Correct 49 ms 39916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1086 ms 39672 KB Time limit exceeded
2 Execution timed out 1079 ms 39672 KB Time limit exceeded
3 Execution timed out 1081 ms 39800 KB Time limit exceeded
4 Execution timed out 1083 ms 39900 KB Time limit exceeded
5 Execution timed out 1087 ms 39800 KB Time limit exceeded
6 Execution timed out 1092 ms 39672 KB Time limit exceeded
7 Execution timed out 1091 ms 39928 KB Time limit exceeded
8 Execution timed out 1070 ms 39672 KB Time limit exceeded
9 Execution timed out 1077 ms 39672 KB Time limit exceeded
10 Correct 649 ms 39688 KB Output is correct
11 Correct 633 ms 39692 KB Output is correct
12 Correct 906 ms 39816 KB Output is correct
13 Execution timed out 1075 ms 39752 KB Time limit exceeded
14 Correct 80 ms 40824 KB Output is correct
15 Correct 954 ms 39680 KB Output is correct
16 Execution timed out 1087 ms 39544 KB Time limit exceeded
17 Execution timed out 1088 ms 39672 KB Time limit exceeded
18 Execution timed out 1084 ms 39672 KB Time limit exceeded
19 Correct 611 ms 39800 KB Output is correct
20 Execution timed out 1087 ms 39840 KB Time limit exceeded
21 Correct 105 ms 40440 KB Output is correct
22 Execution timed out 1082 ms 39800 KB Time limit exceeded
23 Execution timed out 1082 ms 39544 KB Time limit exceeded
24 Correct 475 ms 39800 KB Output is correct
25 Execution timed out 1080 ms 39928 KB Time limit exceeded
26 Execution timed out 1079 ms 39720 KB Time limit exceeded
27 Execution timed out 1066 ms 39928 KB Time limit exceeded
28 Correct 415 ms 39800 KB Output is correct
29 Execution timed out 1083 ms 39800 KB Time limit exceeded
30 Execution timed out 1085 ms 39672 KB Time limit exceeded
31 Execution timed out 1065 ms 39716 KB Time limit exceeded
32 Execution timed out 1085 ms 39800 KB Time limit exceeded
33 Correct 479 ms 39800 KB Output is correct
34 Execution timed out 1081 ms 39896 KB Time limit exceeded
35 Correct 771 ms 39960 KB Output is correct
36 Execution timed out 1061 ms 39800 KB Time limit exceeded
37 Execution timed out 1079 ms 39800 KB Time limit exceeded
38 Execution timed out 1090 ms 39672 KB Time limit exceeded
39 Correct 962 ms 39984 KB Output is correct
40 Execution timed out 1082 ms 39772 KB Time limit exceeded
41 Execution timed out 1064 ms 39900 KB Time limit exceeded
42 Execution timed out 1084 ms 40000 KB Time limit exceeded