Submission #162958

# Submission time Handle Problem Language Result Execution time Memory
162958 2019-11-10T12:08:03 Z dantoh000 Bali Sculptures (APIO15_sculpture) C++14
50 / 100
102 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){
            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 376 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 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 252 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Incorrect 2 ms 376 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 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 4 ms 376 KB Output is correct
5 Correct 2 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 2 ms 256 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 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Incorrect 2 ms 376 KB Output isn't correct
16 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 376 KB Output is correct
6 Correct 1 ms 380 KB Output is correct
7 Correct 2 ms 256 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 252 KB Output is correct
13 Correct 2 ms 376 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 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 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 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 4 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 7 ms 376 KB Output is correct
30 Correct 3 ms 256 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
# 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 376 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 380 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 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Incorrect 2 ms 256 KB Output isn't correct
16 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 376 KB Output is correct
5 Correct 2 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 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 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 360 KB Output is correct
14 Correct 2 ms 424 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 312 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 392 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 376 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 376 KB Output is correct
27 Correct 2 ms 252 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 424 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 3 ms 376 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 3 ms 256 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 400 KB Output is correct
48 Correct 3 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 3 ms 376 KB Output is correct
52 Correct 9 ms 376 KB Output is correct
53 Correct 8 ms 376 KB Output is correct
54 Correct 29 ms 404 KB Output is correct
55 Correct 20 ms 376 KB Output is correct
56 Correct 41 ms 376 KB Output is correct
57 Correct 37 ms 504 KB Output is correct
58 Correct 46 ms 376 KB Output is correct
59 Correct 72 ms 464 KB Output is correct
60 Correct 50 ms 468 KB Output is correct
61 Correct 2 ms 376 KB Output is correct
62 Correct 8 ms 376 KB Output is correct
63 Correct 30 ms 424 KB Output is correct
64 Correct 12 ms 504 KB Output is correct
65 Correct 20 ms 376 KB Output is correct
66 Correct 28 ms 376 KB Output is correct
67 Correct 37 ms 412 KB Output is correct
68 Correct 102 ms 504 KB Output is correct
69 Correct 35 ms 504 KB Output is correct