Submission #43936

# Submission time Handle Problem Language Result Execution time Memory
43936 2018-03-28T12:01:11 Z Kerim Bali Sculptures (APIO15_sculpture) C++17
71 / 100
1000 ms 18008 KB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=2005;
int dp[N][N];
ll par[N];
int n,a,b;
int rec(int pos,int comp,ll mask){
	if(comp>b)
		return 0;
	if(pos>n)
		return (a<=comp);
	int &ret=dp[pos][comp];
	if(~ret)
		return ret;ret=0;
	for(int i=pos;i<=n;i++){
		ll sum=par[i]-par[pos-1];
		if((mask&sum)==sum and rec(i+1,comp+1,mask))
			return ret=1;
	}return ret;
}
int main(){
    //~ freopen("file.in", "r", stdin);
    scanf("%d%d%d",&n,&a,&b);
    for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		par[i]=par[i-1]+x;
	}
	ll ans=(1LL<<45)-1;	
	for(int i=44;i>=0;i--){
		memset(dp,-1,sizeof dp);
		if(rec(1,0,ans-(1LL<<i)))
			ans-=(1LL<<i);
	}
	printf("%lld\n",ans);
	return 0;
}

Compilation message

sculpture.cpp: In function 'int rec(int, int, ll)':
sculpture.cpp:30:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if(~ret)
  ^~
sculpture.cpp:31:14: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   return ret;ret=0;
              ^~~
sculpture.cpp: In function 'int main()':
sculpture.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&a,&b);
     ~~~~~^~~~~~~~~~~~~~~~~~~
sculpture.cpp:43: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 53 ms 16120 KB Output is correct
2 Correct 54 ms 16368 KB Output is correct
3 Correct 51 ms 16368 KB Output is correct
4 Correct 54 ms 16368 KB Output is correct
5 Correct 51 ms 16368 KB Output is correct
6 Correct 52 ms 16368 KB Output is correct
7 Correct 54 ms 16428 KB Output is correct
8 Correct 54 ms 16428 KB Output is correct
9 Correct 73 ms 16428 KB Output is correct
10 Correct 58 ms 16428 KB Output is correct
11 Correct 59 ms 16472 KB Output is correct
12 Correct 56 ms 16472 KB Output is correct
13 Correct 50 ms 16480 KB Output is correct
14 Correct 70 ms 16480 KB Output is correct
15 Correct 54 ms 16480 KB Output is correct
16 Correct 57 ms 16480 KB Output is correct
17 Correct 52 ms 16524 KB Output is correct
18 Correct 54 ms 16524 KB Output is correct
19 Correct 51 ms 16524 KB Output is correct
20 Correct 54 ms 16524 KB Output is correct
21 Correct 53 ms 16524 KB Output is correct
22 Correct 52 ms 16524 KB Output is correct
23 Correct 59 ms 16568 KB Output is correct
24 Correct 54 ms 16568 KB Output is correct
25 Correct 54 ms 16568 KB Output is correct
26 Correct 58 ms 16568 KB Output is correct
27 Correct 53 ms 16568 KB Output is correct
28 Correct 54 ms 16588 KB Output is correct
29 Correct 54 ms 16588 KB Output is correct
30 Correct 59 ms 16588 KB Output is correct
31 Correct 57 ms 16588 KB Output is correct
32 Correct 70 ms 16588 KB Output is correct
33 Correct 63 ms 16588 KB Output is correct
34 Correct 60 ms 16588 KB Output is correct
35 Correct 56 ms 16588 KB Output is correct
36 Correct 53 ms 16588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 16588 KB Output is correct
2 Correct 57 ms 16588 KB Output is correct
3 Correct 73 ms 16608 KB Output is correct
4 Correct 64 ms 16608 KB Output is correct
5 Correct 69 ms 16608 KB Output is correct
6 Correct 54 ms 16608 KB Output is correct
7 Correct 56 ms 16608 KB Output is correct
8 Correct 62 ms 16748 KB Output is correct
9 Correct 61 ms 16748 KB Output is correct
10 Correct 66 ms 16748 KB Output is correct
11 Correct 70 ms 16748 KB Output is correct
12 Correct 67 ms 16748 KB Output is correct
13 Correct 64 ms 16748 KB Output is correct
14 Correct 61 ms 16748 KB Output is correct
15 Correct 55 ms 16748 KB Output is correct
16 Correct 54 ms 16748 KB Output is correct
17 Correct 62 ms 16748 KB Output is correct
18 Correct 61 ms 16748 KB Output is correct
19 Correct 54 ms 16748 KB Output is correct
20 Correct 57 ms 16748 KB Output is correct
21 Correct 57 ms 16748 KB Output is correct
22 Correct 58 ms 16748 KB Output is correct
23 Correct 60 ms 16748 KB Output is correct
24 Correct 64 ms 16748 KB Output is correct
25 Correct 58 ms 16748 KB Output is correct
26 Correct 54 ms 16748 KB Output is correct
27 Correct 60 ms 16748 KB Output is correct
28 Correct 54 ms 16748 KB Output is correct
29 Correct 57 ms 16748 KB Output is correct
30 Correct 59 ms 16748 KB Output is correct
31 Correct 65 ms 16748 KB Output is correct
32 Correct 68 ms 16748 KB Output is correct
33 Correct 56 ms 16748 KB Output is correct
34 Correct 57 ms 16776 KB Output is correct
35 Correct 55 ms 16776 KB Output is correct
36 Correct 60 ms 16776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 16776 KB Output is correct
2 Correct 61 ms 16776 KB Output is correct
3 Correct 58 ms 16776 KB Output is correct
4 Correct 63 ms 16776 KB Output is correct
5 Correct 60 ms 16776 KB Output is correct
6 Correct 57 ms 16776 KB Output is correct
7 Correct 56 ms 16780 KB Output is correct
8 Correct 65 ms 16780 KB Output is correct
9 Correct 59 ms 16784 KB Output is correct
10 Correct 56 ms 16784 KB Output is correct
11 Correct 51 ms 16784 KB Output is correct
12 Correct 57 ms 16820 KB Output is correct
13 Correct 54 ms 16820 KB Output is correct
14 Correct 59 ms 16820 KB Output is correct
15 Correct 60 ms 16820 KB Output is correct
16 Correct 62 ms 16820 KB Output is correct
17 Correct 67 ms 16820 KB Output is correct
18 Correct 68 ms 16848 KB Output is correct
19 Correct 58 ms 16848 KB Output is correct
20 Correct 55 ms 16848 KB Output is correct
21 Correct 67 ms 16848 KB Output is correct
22 Correct 78 ms 16944 KB Output is correct
23 Correct 56 ms 16944 KB Output is correct
24 Correct 64 ms 16944 KB Output is correct
25 Correct 61 ms 16944 KB Output is correct
26 Correct 65 ms 16944 KB Output is correct
27 Correct 56 ms 16944 KB Output is correct
28 Correct 69 ms 16944 KB Output is correct
29 Correct 75 ms 16944 KB Output is correct
30 Correct 56 ms 16944 KB Output is correct
31 Correct 61 ms 16944 KB Output is correct
32 Correct 54 ms 16944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 16944 KB Output is correct
2 Correct 59 ms 16944 KB Output is correct
3 Correct 59 ms 16944 KB Output is correct
4 Correct 59 ms 16944 KB Output is correct
5 Correct 67 ms 16952 KB Output is correct
6 Correct 55 ms 16956 KB Output is correct
7 Correct 63 ms 16956 KB Output is correct
8 Correct 59 ms 16956 KB Output is correct
9 Correct 82 ms 16956 KB Output is correct
10 Correct 54 ms 16956 KB Output is correct
11 Correct 62 ms 16956 KB Output is correct
12 Correct 55 ms 16956 KB Output is correct
13 Correct 56 ms 16956 KB Output is correct
14 Correct 55 ms 16988 KB Output is correct
15 Correct 58 ms 16988 KB Output is correct
16 Correct 59 ms 16988 KB Output is correct
17 Correct 63 ms 16988 KB Output is correct
18 Correct 54 ms 16988 KB Output is correct
19 Correct 56 ms 16988 KB Output is correct
20 Correct 52 ms 16988 KB Output is correct
21 Correct 53 ms 16988 KB Output is correct
22 Correct 55 ms 17152 KB Output is correct
23 Correct 63 ms 17152 KB Output is correct
24 Correct 63 ms 17152 KB Output is correct
25 Correct 59 ms 17152 KB Output is correct
26 Correct 57 ms 17152 KB Output is correct
27 Correct 56 ms 17152 KB Output is correct
28 Correct 55 ms 17152 KB Output is correct
29 Correct 57 ms 17152 KB Output is correct
30 Correct 62 ms 17152 KB Output is correct
31 Correct 57 ms 17152 KB Output is correct
32 Correct 60 ms 17152 KB Output is correct
33 Correct 58 ms 17156 KB Output is correct
34 Correct 60 ms 17156 KB Output is correct
35 Correct 67 ms 17156 KB Output is correct
36 Correct 66 ms 17156 KB Output is correct
37 Correct 60 ms 17156 KB Output is correct
38 Correct 58 ms 17156 KB Output is correct
39 Correct 61 ms 17156 KB Output is correct
40 Correct 56 ms 17156 KB Output is correct
41 Correct 55 ms 17156 KB Output is correct
42 Correct 59 ms 17172 KB Output is correct
43 Correct 67 ms 17172 KB Output is correct
44 Correct 58 ms 17172 KB Output is correct
45 Correct 70 ms 17172 KB Output is correct
46 Correct 60 ms 17284 KB Output is correct
47 Correct 69 ms 17284 KB Output is correct
48 Correct 60 ms 17284 KB Output is correct
49 Correct 52 ms 17284 KB Output is correct
50 Correct 61 ms 17284 KB Output is correct
51 Correct 60 ms 17284 KB Output is correct
52 Correct 56 ms 17284 KB Output is correct
53 Correct 63 ms 17284 KB Output is correct
54 Correct 64 ms 17284 KB Output is correct
55 Correct 78 ms 17284 KB Output is correct
56 Correct 60 ms 17284 KB Output is correct
57 Correct 62 ms 17284 KB Output is correct
58 Correct 54 ms 17284 KB Output is correct
59 Correct 66 ms 17284 KB Output is correct
60 Correct 55 ms 17284 KB Output is correct
61 Correct 68 ms 17284 KB Output is correct
62 Correct 69 ms 17284 KB Output is correct
63 Correct 58 ms 17284 KB Output is correct
64 Correct 61 ms 17284 KB Output is correct
65 Correct 60 ms 17284 KB Output is correct
66 Correct 56 ms 17284 KB Output is correct
67 Correct 55 ms 17284 KB Output is correct
68 Correct 57 ms 17320 KB Output is correct
69 Correct 55 ms 17320 KB Output is correct
70 Correct 66 ms 17320 KB Output is correct
71 Correct 69 ms 17332 KB Output is correct
72 Correct 61 ms 17332 KB Output is correct
73 Correct 66 ms 17332 KB Output is correct
74 Correct 58 ms 17332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 17332 KB Output is correct
2 Correct 56 ms 17332 KB Output is correct
3 Correct 57 ms 17332 KB Output is correct
4 Correct 56 ms 17332 KB Output is correct
5 Correct 59 ms 17332 KB Output is correct
6 Correct 57 ms 17332 KB Output is correct
7 Correct 60 ms 17332 KB Output is correct
8 Correct 58 ms 17332 KB Output is correct
9 Correct 57 ms 17332 KB Output is correct
10 Correct 54 ms 17384 KB Output is correct
11 Correct 63 ms 17384 KB Output is correct
12 Correct 55 ms 17384 KB Output is correct
13 Correct 58 ms 17384 KB Output is correct
14 Correct 55 ms 17400 KB Output is correct
15 Correct 65 ms 17400 KB Output is correct
16 Correct 54 ms 17400 KB Output is correct
17 Correct 60 ms 17400 KB Output is correct
18 Correct 55 ms 17400 KB Output is correct
19 Correct 58 ms 17400 KB Output is correct
20 Correct 55 ms 17400 KB Output is correct
21 Correct 51 ms 17400 KB Output is correct
22 Correct 54 ms 17400 KB Output is correct
23 Correct 57 ms 17400 KB Output is correct
24 Correct 68 ms 17416 KB Output is correct
25 Correct 58 ms 17416 KB Output is correct
26 Correct 58 ms 17416 KB Output is correct
27 Correct 55 ms 17452 KB Output is correct
28 Correct 59 ms 17452 KB Output is correct
29 Correct 58 ms 17452 KB Output is correct
30 Correct 66 ms 17464 KB Output is correct
31 Correct 61 ms 17468 KB Output is correct
32 Correct 57 ms 17468 KB Output is correct
33 Correct 57 ms 17468 KB Output is correct
34 Correct 56 ms 17468 KB Output is correct
35 Correct 56 ms 17468 KB Output is correct
36 Correct 63 ms 17488 KB Output is correct
37 Correct 58 ms 17488 KB Output is correct
38 Correct 53 ms 17488 KB Output is correct
39 Correct 55 ms 17488 KB Output is correct
40 Correct 57 ms 17492 KB Output is correct
41 Correct 60 ms 17492 KB Output is correct
42 Correct 55 ms 17492 KB Output is correct
43 Correct 53 ms 17492 KB Output is correct
44 Correct 56 ms 17492 KB Output is correct
45 Correct 53 ms 17492 KB Output is correct
46 Correct 55 ms 17492 KB Output is correct
47 Correct 57 ms 17528 KB Output is correct
48 Correct 58 ms 17544 KB Output is correct
49 Correct 55 ms 17544 KB Output is correct
50 Correct 55 ms 17544 KB Output is correct
51 Correct 65 ms 17544 KB Output is correct
52 Correct 232 ms 17552 KB Output is correct
53 Correct 53 ms 17568 KB Output is correct
54 Correct 456 ms 17700 KB Output is correct
55 Correct 398 ms 17768 KB Output is correct
56 Correct 917 ms 17768 KB Output is correct
57 Correct 56 ms 17816 KB Output is correct
58 Correct 64 ms 17980 KB Output is correct
59 Correct 66 ms 18000 KB Output is correct
60 Correct 145 ms 18000 KB Output is correct
61 Correct 57 ms 18000 KB Output is correct
62 Correct 55 ms 18000 KB Output is correct
63 Correct 485 ms 18000 KB Output is correct
64 Correct 58 ms 18000 KB Output is correct
65 Correct 536 ms 18000 KB Output is correct
66 Correct 54 ms 18004 KB Output is correct
67 Correct 136 ms 18008 KB Output is correct
68 Execution timed out 1081 ms 18008 KB Time limit exceeded
69 Halted 0 ms 0 KB -