Submission #41852

# Submission time Handle Problem Language Result Execution time Memory
41852 2018-02-21T15:19:34 Z XmtosX Bali Sculptures (APIO15_sculpture) C++14
100 / 100
591 ms 1124 KB
#include <bits/stdc++.h>
using namespace std;
int n,a,b;
long long y[2003],ans,o,memo1[2003];
bool memo[102][102],vis[102][102];
bool dp (int pos,int cnt)
{
    if (pos==n)
    {
        if (cnt>=a&&cnt<=b)
            return 1;
        return 0;
    }
    if (vis[pos][cnt])
        return memo[pos][cnt];
    vis[pos][cnt]=true;
    long long sum=0;
    for (int i=pos;i<n;i++)
    {
        sum+=y[i];
        bool flag=false;
        for (long long j=40;(1LL<<j)>=o;j--)
        {
            if ((sum&(1LL<<j))>((ans&(1LL<<j))))
            {
                flag=true;
                break;
            }
        }
        if (!flag)
            memo[pos][cnt]|=dp(i+1,cnt+1);
    }
    return memo[pos][cnt];
}
long long dp1 (int pos)
{
    if (pos==n)
        return 0;
    if (memo1[pos]!=-1)
        return memo1[pos];
    memo1[pos]=1e9;
    long long sum=0;
    for (int i=pos;i<n;i++)
    {
        sum+=y[i];
        bool flag=false;
        for (long long j=40;(1LL<<j)>=o;j--)
        {
            if ((sum&(1LL<<j))>((ans&(1LL<<j))))
            {
                flag=true;
                break;
            }
        }
        if (!flag)
            memo1[pos]=min(memo1[pos],dp1(i+1)+1);
    }
    return memo1[pos];
}
int main()
{
    cin >>n>>a>>b;
    for (int i=0;i<n;i++)
        cin >>y[i];
    if (a==1)
    {
        for (long long i=40;i>=0;i--)
        {
            memset(memo1,-1,sizeof memo1);
            o=(1LL<<i);
            if (dp1(0)>b)
                ans|=o;
        }
    }
    else
    {
        for (long long i=40;i>=0;i--)
        {
            memset(vis,0,sizeof vis);
            memset(memo,0,sizeof memo);
            o=(1LL<<i);
            if (!dp(0,0))
                ans|=o;
        }
    }
    cout <<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 424 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 2 ms 476 KB Output is correct
7 Correct 2 ms 528 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 2 ms 640 KB Output is correct
11 Correct 2 ms 640 KB Output is correct
12 Correct 2 ms 660 KB Output is correct
13 Correct 2 ms 660 KB Output is correct
14 Correct 1 ms 660 KB Output is correct
15 Correct 1 ms 660 KB Output is correct
16 Correct 1 ms 660 KB Output is correct
17 Correct 1 ms 660 KB Output is correct
18 Correct 2 ms 660 KB Output is correct
19 Correct 2 ms 660 KB Output is correct
20 Correct 2 ms 660 KB Output is correct
21 Correct 3 ms 660 KB Output is correct
22 Correct 3 ms 660 KB Output is correct
23 Correct 4 ms 660 KB Output is correct
24 Correct 3 ms 660 KB Output is correct
25 Correct 3 ms 660 KB Output is correct
26 Correct 3 ms 660 KB Output is correct
27 Correct 1 ms 660 KB Output is correct
28 Correct 1 ms 660 KB Output is correct
29 Correct 2 ms 660 KB Output is correct
30 Correct 2 ms 660 KB Output is correct
31 Correct 2 ms 660 KB Output is correct
32 Correct 1 ms 660 KB Output is correct
33 Correct 2 ms 660 KB Output is correct
34 Correct 2 ms 660 KB Output is correct
35 Correct 2 ms 660 KB Output is correct
36 Correct 2 ms 660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 660 KB Output is correct
2 Correct 2 ms 660 KB Output is correct
3 Correct 1 ms 660 KB Output is correct
4 Correct 2 ms 660 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 1 ms 660 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 2 ms 660 KB Output is correct
9 Correct 2 ms 660 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 2 ms 660 KB Output is correct
13 Correct 2 ms 660 KB Output is correct
14 Correct 1 ms 660 KB Output is correct
15 Correct 2 ms 660 KB Output is correct
16 Correct 2 ms 660 KB Output is correct
17 Correct 1 ms 660 KB Output is correct
18 Correct 2 ms 660 KB Output is correct
19 Correct 2 ms 660 KB Output is correct
20 Correct 2 ms 660 KB Output is correct
21 Correct 3 ms 660 KB Output is correct
22 Correct 3 ms 660 KB Output is correct
23 Correct 3 ms 660 KB Output is correct
24 Correct 3 ms 660 KB Output is correct
25 Correct 3 ms 660 KB Output is correct
26 Correct 3 ms 660 KB Output is correct
27 Correct 2 ms 660 KB Output is correct
28 Correct 2 ms 660 KB Output is correct
29 Correct 2 ms 660 KB Output is correct
30 Correct 2 ms 660 KB Output is correct
31 Correct 4 ms 660 KB Output is correct
32 Correct 4 ms 660 KB Output is correct
33 Correct 3 ms 660 KB Output is correct
34 Correct 3 ms 660 KB Output is correct
35 Correct 3 ms 660 KB Output is correct
36 Correct 3 ms 660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 660 KB Output is correct
2 Correct 1 ms 660 KB Output is correct
3 Correct 1 ms 660 KB Output is correct
4 Correct 1 ms 660 KB Output is correct
5 Correct 1 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 2 ms 660 KB Output is correct
9 Correct 2 ms 660 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 2 ms 660 KB Output is correct
13 Correct 2 ms 660 KB Output is correct
14 Correct 2 ms 660 KB Output is correct
15 Correct 2 ms 660 KB Output is correct
16 Correct 2 ms 660 KB Output is correct
17 Correct 2 ms 660 KB Output is correct
18 Correct 4 ms 748 KB Output is correct
19 Correct 3 ms 768 KB Output is correct
20 Correct 4 ms 768 KB Output is correct
21 Correct 3 ms 768 KB Output is correct
22 Correct 3 ms 768 KB Output is correct
23 Correct 3 ms 768 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 4 ms 768 KB Output is correct
26 Correct 5 ms 768 KB Output is correct
27 Correct 5 ms 768 KB Output is correct
28 Correct 6 ms 768 KB Output is correct
29 Correct 7 ms 768 KB Output is correct
30 Correct 7 ms 768 KB Output is correct
31 Correct 7 ms 768 KB Output is correct
32 Correct 6 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 768 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 2 ms 768 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 2 ms 768 KB Output is correct
17 Correct 1 ms 768 KB Output is correct
18 Correct 2 ms 768 KB Output is correct
19 Correct 2 ms 768 KB Output is correct
20 Correct 2 ms 768 KB Output is correct
21 Correct 3 ms 768 KB Output is correct
22 Correct 4 ms 768 KB Output is correct
23 Correct 3 ms 768 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 3 ms 768 KB Output is correct
26 Correct 3 ms 768 KB Output is correct
27 Correct 2 ms 768 KB Output is correct
28 Correct 1 ms 768 KB Output is correct
29 Correct 2 ms 768 KB Output is correct
30 Correct 2 ms 768 KB Output is correct
31 Correct 2 ms 768 KB Output is correct
32 Correct 2 ms 768 KB Output is correct
33 Correct 2 ms 768 KB Output is correct
34 Correct 2 ms 768 KB Output is correct
35 Correct 2 ms 768 KB Output is correct
36 Correct 2 ms 768 KB Output is correct
37 Correct 2 ms 768 KB Output is correct
38 Correct 2 ms 768 KB Output is correct
39 Correct 2 ms 768 KB Output is correct
40 Correct 3 ms 768 KB Output is correct
41 Correct 3 ms 768 KB Output is correct
42 Correct 3 ms 768 KB Output is correct
43 Correct 3 ms 768 KB Output is correct
44 Correct 3 ms 768 KB Output is correct
45 Correct 3 ms 768 KB Output is correct
46 Correct 3 ms 768 KB Output is correct
47 Correct 3 ms 768 KB Output is correct
48 Correct 5 ms 768 KB Output is correct
49 Correct 5 ms 768 KB Output is correct
50 Correct 6 ms 768 KB Output is correct
51 Correct 10 ms 768 KB Output is correct
52 Correct 7 ms 768 KB Output is correct
53 Correct 7 ms 768 KB Output is correct
54 Correct 6 ms 768 KB Output is correct
55 Correct 6 ms 768 KB Output is correct
56 Correct 2 ms 768 KB Output is correct
57 Correct 2 ms 768 KB Output is correct
58 Correct 2 ms 768 KB Output is correct
59 Correct 2 ms 768 KB Output is correct
60 Correct 3 ms 768 KB Output is correct
61 Correct 2 ms 768 KB Output is correct
62 Correct 3 ms 768 KB Output is correct
63 Correct 3 ms 768 KB Output is correct
64 Correct 161 ms 768 KB Output is correct
65 Correct 5 ms 768 KB Output is correct
66 Correct 9 ms 768 KB Output is correct
67 Correct 12 ms 768 KB Output is correct
68 Correct 19 ms 768 KB Output is correct
69 Correct 21 ms 768 KB Output is correct
70 Correct 19 ms 768 KB Output is correct
71 Correct 24 ms 768 KB Output is correct
72 Correct 31 ms 768 KB Output is correct
73 Correct 39 ms 768 KB Output is correct
74 Correct 33 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 2 ms 768 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 1 ms 768 KB Output is correct
17 Correct 2 ms 768 KB Output is correct
18 Correct 1 ms 768 KB Output is correct
19 Correct 1 ms 768 KB Output is correct
20 Correct 2 ms 768 KB Output is correct
21 Correct 2 ms 768 KB Output is correct
22 Correct 2 ms 768 KB Output is correct
23 Correct 2 ms 768 KB Output is correct
24 Correct 2 ms 768 KB Output is correct
25 Correct 2 ms 768 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 2 ms 768 KB Output is correct
28 Correct 4 ms 768 KB Output is correct
29 Correct 3 ms 768 KB Output is correct
30 Correct 3 ms 768 KB Output is correct
31 Correct 3 ms 768 KB Output is correct
32 Correct 3 ms 768 KB Output is correct
33 Correct 3 ms 768 KB Output is correct
34 Correct 3 ms 768 KB Output is correct
35 Correct 4 ms 768 KB Output is correct
36 Correct 5 ms 768 KB Output is correct
37 Correct 6 ms 768 KB Output is correct
38 Correct 7 ms 768 KB Output is correct
39 Correct 7 ms 768 KB Output is correct
40 Correct 8 ms 768 KB Output is correct
41 Correct 8 ms 768 KB Output is correct
42 Correct 7 ms 768 KB Output is correct
43 Correct 2 ms 768 KB Output is correct
44 Correct 3 ms 768 KB Output is correct
45 Correct 2 ms 768 KB Output is correct
46 Correct 2 ms 768 KB Output is correct
47 Correct 3 ms 768 KB Output is correct
48 Correct 2 ms 768 KB Output is correct
49 Correct 3 ms 768 KB Output is correct
50 Correct 3 ms 768 KB Output is correct
51 Correct 3 ms 768 KB Output is correct
52 Correct 42 ms 768 KB Output is correct
53 Correct 27 ms 768 KB Output is correct
54 Correct 197 ms 768 KB Output is correct
55 Correct 128 ms 768 KB Output is correct
56 Correct 182 ms 768 KB Output is correct
57 Correct 145 ms 768 KB Output is correct
58 Correct 200 ms 768 KB Output is correct
59 Correct 308 ms 768 KB Output is correct
60 Correct 296 ms 784 KB Output is correct
61 Correct 3 ms 784 KB Output is correct
62 Correct 26 ms 808 KB Output is correct
63 Correct 186 ms 808 KB Output is correct
64 Correct 41 ms 808 KB Output is correct
65 Correct 77 ms 808 KB Output is correct
66 Correct 102 ms 928 KB Output is correct
67 Correct 144 ms 956 KB Output is correct
68 Correct 591 ms 1104 KB Output is correct
69 Correct 130 ms 1124 KB Output is correct