Submission #162959

# Submission time Handle Problem Language Result Execution time Memory
162959 2019-11-10T12:08:39 Z dantoh000 Bali Sculptures (APIO15_sculpture) C++14
50 / 100
110 ms 504 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int memo[2005];
ll p[2005];
int c[2005];
int a,b;
ll ans;
const int INF = 2005;
int dp(int id){
    //printf("dp %d %lld\n",id,ans);
    if (id == n) return 0;
    if (memo[id] != -1) return memo[id];
    int cur = INF;
    for (int i = id+1; i <= n; i++){
        ll sum = p[i]-p[id];
        //printf("%lld %lld %lld\n",sum,ans,sum&ans);
        ll k = sum&ans;
        if (k == 0ll){
            cur = min(cur,dp(i)+1);
        }
    }
    return memo[id] = cur;
}
int main(){
    scanf("%d%d%d",&n,&a,&b);
    p[0] = 0;
    for (int i = 1; i <= n; i++){
        scanf("%d",&c[i]);
        p[i] = p[i-1] + c[i];
    }
    ans = 0;
    for (int i = 40; i >= 0; i--){
        memset(memo,-1,sizeof(memo));
        ans += (1ll<<i);
        dp(0);
        /*for (int i = 0; i < n; i++){
            printf("%d ",memo[i]);
        }
        printf("\n");
        printf("if want to split to %lld, need %d\n",(1ll<<41)-1-ans,dp(0));*/
        if (dp(0) > b || dp(0) < a){
            ans -= (1ll<<i);
        }
    }
    printf("%lld ",(1ll<<41)-1-ans);



}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:27: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:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&c[i]);
         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Incorrect 2 ms 380 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 252 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Incorrect 2 ms 252 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 10 ms 252 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 3 ms 256 KB Output is correct
28 Correct 3 ms 256 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 256 KB Output is correct
32 Correct 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 252 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 252 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Incorrect 2 ms 256 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 296 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 452 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 2 ms 380 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 2 ms 380 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 3 ms 256 KB Output is correct
37 Correct 3 ms 256 KB Output is correct
38 Correct 3 ms 376 KB Output is correct
39 Correct 3 ms 376 KB Output is correct
40 Correct 3 ms 376 KB Output is correct
41 Correct 3 ms 376 KB Output is correct
42 Correct 3 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 380 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 256 KB Output is correct
49 Correct 3 ms 380 KB Output is correct
50 Correct 3 ms 376 KB Output is correct
51 Correct 2 ms 256 KB Output is correct
52 Correct 10 ms 388 KB Output is correct
53 Correct 10 ms 376 KB Output is correct
54 Correct 32 ms 376 KB Output is correct
55 Correct 23 ms 376 KB Output is correct
56 Correct 49 ms 376 KB Output is correct
57 Correct 44 ms 376 KB Output is correct
58 Correct 52 ms 376 KB Output is correct
59 Correct 94 ms 380 KB Output is correct
60 Correct 61 ms 376 KB Output is correct
61 Correct 2 ms 376 KB Output is correct
62 Correct 10 ms 376 KB Output is correct
63 Correct 34 ms 408 KB Output is correct
64 Correct 14 ms 504 KB Output is correct
65 Correct 24 ms 376 KB Output is correct
66 Correct 34 ms 376 KB Output is correct
67 Correct 46 ms 504 KB Output is correct
68 Correct 110 ms 376 KB Output is correct
69 Correct 41 ms 376 KB Output is correct