Submission #23118

# Submission time Handle Problem Language Result Execution time Memory
23118 2017-05-03T07:51:11 Z ngkan146 Bali Sculptures (APIO15_sculpture) C++
100 / 100
113 ms 5968 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a,b,x[2005];
ll res = 0;
bool dp[2005][2005];
int dp2[2005];
int main(){
   cin >> n >> a >> b;
   for(int i=1;i<=n;i++)
      cin >> x[i];
   if (a > 1){
      for(int bit=40;bit>=0;bit--){
         memset(dp,0,sizeof(dp));
         dp[0][0] = 1;
         for(int i=0;i<=n;i++){
            for(int j=0;j<=i;j++){
               if (!dp[i][j]) continue;
               ll sum = 0;
               for(int k=i+1;k<=n;k++){
                  sum += x[k];
                  if (((sum>>bit)|(res>>bit)) == (res>>bit))
                     dp[k][j+1] = 1;
               }
            }
         }
         bool ok = 0;
         for(int j=a;j<=b;j++)
            if (dp[n][j]) ok = 1;
         if (!ok) res += (1ll<<bit);
      }
   }
   else{
      for(int bit=40;bit>=0;bit--){
         fill(dp2,dp2+n+1,(int)1e9);
         dp2[0] = 0;
         for(int i=0;i<=n;i++){
            if (dp2[i] == (int)1e9) continue;
            ll sum = 0;
            for(int k=i+1;k<=n;k++){
               sum += x[k];
               if (((sum>>bit)|(res>>bit)) == (res>>bit))
                  dp2[k] = min(dp2[k], dp2[i]+1);
            }
         }
         if (dp2[n] > b) res += (1ll<<bit);
      }
   }
   cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5968 KB Output is correct
2 Correct 0 ms 5968 KB Output is correct
3 Correct 0 ms 5968 KB Output is correct
4 Correct 0 ms 5968 KB Output is correct
5 Correct 0 ms 5968 KB Output is correct
6 Correct 0 ms 5968 KB Output is correct
7 Correct 0 ms 5968 KB Output is correct
8 Correct 0 ms 5968 KB Output is correct
9 Correct 0 ms 5968 KB Output is correct
10 Correct 0 ms 5968 KB Output is correct
11 Correct 0 ms 5968 KB Output is correct
12 Correct 0 ms 5968 KB Output is correct
13 Correct 0 ms 5968 KB Output is correct
14 Correct 9 ms 5968 KB Output is correct
15 Correct 6 ms 5968 KB Output is correct
16 Correct 6 ms 5968 KB Output is correct
17 Correct 9 ms 5968 KB Output is correct
18 Correct 9 ms 5968 KB Output is correct
19 Correct 6 ms 5968 KB Output is correct
20 Correct 6 ms 5968 KB Output is correct
21 Correct 9 ms 5968 KB Output is correct
22 Correct 9 ms 5968 KB Output is correct
23 Correct 9 ms 5968 KB Output is correct
24 Correct 9 ms 5968 KB Output is correct
25 Correct 9 ms 5968 KB Output is correct
26 Correct 9 ms 5968 KB Output is correct
27 Correct 0 ms 5968 KB Output is correct
28 Correct 0 ms 5968 KB Output is correct
29 Correct 0 ms 5968 KB Output is correct
30 Correct 0 ms 5968 KB Output is correct
31 Correct 0 ms 5968 KB Output is correct
32 Correct 0 ms 5968 KB Output is correct
33 Correct 0 ms 5968 KB Output is correct
34 Correct 0 ms 5968 KB Output is correct
35 Correct 0 ms 5968 KB Output is correct
36 Correct 0 ms 5968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5968 KB Output is correct
2 Correct 0 ms 5968 KB Output is correct
3 Correct 0 ms 5968 KB Output is correct
4 Correct 0 ms 5968 KB Output is correct
5 Correct 0 ms 5968 KB Output is correct
6 Correct 0 ms 5968 KB Output is correct
7 Correct 0 ms 5968 KB Output is correct
8 Correct 0 ms 5968 KB Output is correct
9 Correct 0 ms 5968 KB Output is correct
10 Correct 0 ms 5968 KB Output is correct
11 Correct 0 ms 5968 KB Output is correct
12 Correct 0 ms 5968 KB Output is correct
13 Correct 0 ms 5968 KB Output is correct
14 Correct 6 ms 5968 KB Output is correct
15 Correct 9 ms 5968 KB Output is correct
16 Correct 6 ms 5968 KB Output is correct
17 Correct 6 ms 5968 KB Output is correct
18 Correct 6 ms 5968 KB Output is correct
19 Correct 6 ms 5968 KB Output is correct
20 Correct 9 ms 5968 KB Output is correct
21 Correct 9 ms 5968 KB Output is correct
22 Correct 9 ms 5968 KB Output is correct
23 Correct 6 ms 5968 KB Output is correct
24 Correct 9 ms 5968 KB Output is correct
25 Correct 6 ms 5968 KB Output is correct
26 Correct 6 ms 5968 KB Output is correct
27 Correct 0 ms 5968 KB Output is correct
28 Correct 0 ms 5968 KB Output is correct
29 Correct 0 ms 5968 KB Output is correct
30 Correct 0 ms 5968 KB Output is correct
31 Correct 0 ms 5968 KB Output is correct
32 Correct 0 ms 5968 KB Output is correct
33 Correct 0 ms 5968 KB Output is correct
34 Correct 0 ms 5968 KB Output is correct
35 Correct 0 ms 5968 KB Output is correct
36 Correct 0 ms 5968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5968 KB Output is correct
2 Correct 0 ms 5968 KB Output is correct
3 Correct 0 ms 5968 KB Output is correct
4 Correct 0 ms 5968 KB Output is correct
5 Correct 0 ms 5968 KB Output is correct
6 Correct 0 ms 5968 KB Output is correct
7 Correct 0 ms 5968 KB Output is correct
8 Correct 0 ms 5968 KB Output is correct
9 Correct 0 ms 5968 KB Output is correct
10 Correct 0 ms 5968 KB Output is correct
11 Correct 0 ms 5968 KB Output is correct
12 Correct 0 ms 5968 KB Output is correct
13 Correct 0 ms 5968 KB Output is correct
14 Correct 0 ms 5968 KB Output is correct
15 Correct 0 ms 5968 KB Output is correct
16 Correct 0 ms 5968 KB Output is correct
17 Correct 0 ms 5968 KB Output is correct
18 Correct 0 ms 5968 KB Output is correct
19 Correct 0 ms 5968 KB Output is correct
20 Correct 0 ms 5968 KB Output is correct
21 Correct 0 ms 5968 KB Output is correct
22 Correct 0 ms 5968 KB Output is correct
23 Correct 0 ms 5968 KB Output is correct
24 Correct 0 ms 5968 KB Output is correct
25 Correct 0 ms 5968 KB Output is correct
26 Correct 0 ms 5968 KB Output is correct
27 Correct 0 ms 5968 KB Output is correct
28 Correct 0 ms 5968 KB Output is correct
29 Correct 0 ms 5968 KB Output is correct
30 Correct 0 ms 5968 KB Output is correct
31 Correct 0 ms 5968 KB Output is correct
32 Correct 0 ms 5968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5968 KB Output is correct
2 Correct 0 ms 5968 KB Output is correct
3 Correct 0 ms 5968 KB Output is correct
4 Correct 0 ms 5968 KB Output is correct
5 Correct 0 ms 5968 KB Output is correct
6 Correct 0 ms 5968 KB Output is correct
7 Correct 0 ms 5968 KB Output is correct
8 Correct 0 ms 5968 KB Output is correct
9 Correct 0 ms 5968 KB Output is correct
10 Correct 0 ms 5968 KB Output is correct
11 Correct 0 ms 5968 KB Output is correct
12 Correct 0 ms 5968 KB Output is correct
13 Correct 0 ms 5968 KB Output is correct
14 Correct 9 ms 5968 KB Output is correct
15 Correct 6 ms 5968 KB Output is correct
16 Correct 9 ms 5968 KB Output is correct
17 Correct 9 ms 5968 KB Output is correct
18 Correct 9 ms 5968 KB Output is correct
19 Correct 9 ms 5968 KB Output is correct
20 Correct 6 ms 5968 KB Output is correct
21 Correct 6 ms 5968 KB Output is correct
22 Correct 9 ms 5968 KB Output is correct
23 Correct 9 ms 5968 KB Output is correct
24 Correct 9 ms 5968 KB Output is correct
25 Correct 9 ms 5968 KB Output is correct
26 Correct 9 ms 5968 KB Output is correct
27 Correct 0 ms 5968 KB Output is correct
28 Correct 0 ms 5968 KB Output is correct
29 Correct 0 ms 5968 KB Output is correct
30 Correct 0 ms 5968 KB Output is correct
31 Correct 0 ms 5968 KB Output is correct
32 Correct 0 ms 5968 KB Output is correct
33 Correct 0 ms 5968 KB Output is correct
34 Correct 0 ms 5968 KB Output is correct
35 Correct 0 ms 5968 KB Output is correct
36 Correct 0 ms 5968 KB Output is correct
37 Correct 0 ms 5968 KB Output is correct
38 Correct 0 ms 5968 KB Output is correct
39 Correct 0 ms 5968 KB Output is correct
40 Correct 0 ms 5968 KB Output is correct
41 Correct 0 ms 5968 KB Output is correct
42 Correct 0 ms 5968 KB Output is correct
43 Correct 0 ms 5968 KB Output is correct
44 Correct 0 ms 5968 KB Output is correct
45 Correct 0 ms 5968 KB Output is correct
46 Correct 0 ms 5968 KB Output is correct
47 Correct 0 ms 5968 KB Output is correct
48 Correct 0 ms 5968 KB Output is correct
49 Correct 0 ms 5968 KB Output is correct
50 Correct 0 ms 5968 KB Output is correct
51 Correct 0 ms 5968 KB Output is correct
52 Correct 0 ms 5968 KB Output is correct
53 Correct 0 ms 5968 KB Output is correct
54 Correct 0 ms 5968 KB Output is correct
55 Correct 0 ms 5968 KB Output is correct
56 Correct 0 ms 5968 KB Output is correct
57 Correct 0 ms 5968 KB Output is correct
58 Correct 0 ms 5968 KB Output is correct
59 Correct 0 ms 5968 KB Output is correct
60 Correct 0 ms 5968 KB Output is correct
61 Correct 0 ms 5968 KB Output is correct
62 Correct 0 ms 5968 KB Output is correct
63 Correct 0 ms 5968 KB Output is correct
64 Correct 19 ms 5968 KB Output is correct
65 Correct 9 ms 5968 KB Output is correct
66 Correct 9 ms 5968 KB Output is correct
67 Correct 9 ms 5968 KB Output is correct
68 Correct 6 ms 5968 KB Output is correct
69 Correct 13 ms 5968 KB Output is correct
70 Correct 6 ms 5968 KB Output is correct
71 Correct 13 ms 5968 KB Output is correct
72 Correct 13 ms 5968 KB Output is correct
73 Correct 13 ms 5968 KB Output is correct
74 Correct 13 ms 5968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5968 KB Output is correct
2 Correct 0 ms 5968 KB Output is correct
3 Correct 0 ms 5968 KB Output is correct
4 Correct 0 ms 5968 KB Output is correct
5 Correct 0 ms 5968 KB Output is correct
6 Correct 0 ms 5968 KB Output is correct
7 Correct 0 ms 5968 KB Output is correct
8 Correct 0 ms 5968 KB Output is correct
9 Correct 0 ms 5968 KB Output is correct
10 Correct 0 ms 5968 KB Output is correct
11 Correct 0 ms 5968 KB Output is correct
12 Correct 0 ms 5968 KB Output is correct
13 Correct 0 ms 5968 KB Output is correct
14 Correct 0 ms 5968 KB Output is correct
15 Correct 0 ms 5968 KB Output is correct
16 Correct 0 ms 5968 KB Output is correct
17 Correct 0 ms 5968 KB Output is correct
18 Correct 0 ms 5968 KB Output is correct
19 Correct 0 ms 5968 KB Output is correct
20 Correct 0 ms 5968 KB Output is correct
21 Correct 0 ms 5968 KB Output is correct
22 Correct 0 ms 5968 KB Output is correct
23 Correct 0 ms 5968 KB Output is correct
24 Correct 0 ms 5968 KB Output is correct
25 Correct 0 ms 5968 KB Output is correct
26 Correct 0 ms 5968 KB Output is correct
27 Correct 0 ms 5968 KB Output is correct
28 Correct 0 ms 5968 KB Output is correct
29 Correct 0 ms 5968 KB Output is correct
30 Correct 0 ms 5968 KB Output is correct
31 Correct 0 ms 5968 KB Output is correct
32 Correct 0 ms 5968 KB Output is correct
33 Correct 0 ms 5968 KB Output is correct
34 Correct 0 ms 5968 KB Output is correct
35 Correct 0 ms 5968 KB Output is correct
36 Correct 0 ms 5968 KB Output is correct
37 Correct 0 ms 5968 KB Output is correct
38 Correct 0 ms 5968 KB Output is correct
39 Correct 0 ms 5968 KB Output is correct
40 Correct 0 ms 5968 KB Output is correct
41 Correct 0 ms 5968 KB Output is correct
42 Correct 0 ms 5968 KB Output is correct
43 Correct 0 ms 5968 KB Output is correct
44 Correct 0 ms 5968 KB Output is correct
45 Correct 0 ms 5968 KB Output is correct
46 Correct 0 ms 5968 KB Output is correct
47 Correct 0 ms 5968 KB Output is correct
48 Correct 0 ms 5968 KB Output is correct
49 Correct 0 ms 5968 KB Output is correct
50 Correct 0 ms 5968 KB Output is correct
51 Correct 0 ms 5968 KB Output is correct
52 Correct 6 ms 5968 KB Output is correct
53 Correct 3 ms 5968 KB Output is correct
54 Correct 26 ms 5968 KB Output is correct
55 Correct 19 ms 5968 KB Output is correct
56 Correct 39 ms 5968 KB Output is correct
57 Correct 33 ms 5968 KB Output is correct
58 Correct 53 ms 5968 KB Output is correct
59 Correct 83 ms 5968 KB Output is correct
60 Correct 46 ms 5968 KB Output is correct
61 Correct 0 ms 5968 KB Output is correct
62 Correct 3 ms 5968 KB Output is correct
63 Correct 29 ms 5968 KB Output is correct
64 Correct 6 ms 5968 KB Output is correct
65 Correct 16 ms 5968 KB Output is correct
66 Correct 23 ms 5968 KB Output is correct
67 Correct 33 ms 5968 KB Output is correct
68 Correct 113 ms 5968 KB Output is correct
69 Correct 33 ms 5968 KB Output is correct