Submission #41851

# Submission time Handle Problem Language Result Execution time Memory
41851 2018-02-21T15:19:06 Z XmtosX Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 756 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;
        }
        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 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 472 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 1 ms 480 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 2 ms 500 KB Output is correct
8 Correct 2 ms 500 KB Output is correct
9 Correct 2 ms 500 KB Output is correct
10 Correct 2 ms 500 KB Output is correct
11 Correct 2 ms 548 KB Output is correct
12 Correct 2 ms 548 KB Output is correct
13 Correct 2 ms 548 KB Output is correct
14 Correct 1 ms 548 KB Output is correct
15 Correct 2 ms 548 KB Output is correct
16 Correct 2 ms 548 KB Output is correct
17 Correct 1 ms 548 KB Output is correct
18 Correct 2 ms 548 KB Output is correct
19 Correct 2 ms 548 KB Output is correct
20 Correct 3 ms 548 KB Output is correct
21 Correct 3 ms 600 KB Output is correct
22 Correct 3 ms 600 KB Output is correct
23 Correct 3 ms 728 KB Output is correct
24 Correct 3 ms 728 KB Output is correct
25 Correct 3 ms 728 KB Output is correct
26 Correct 3 ms 728 KB Output is correct
27 Correct 2 ms 728 KB Output is correct
28 Correct 1 ms 728 KB Output is correct
29 Correct 1 ms 728 KB Output is correct
30 Correct 2 ms 728 KB Output is correct
31 Correct 1 ms 728 KB Output is correct
32 Correct 2 ms 728 KB Output is correct
33 Correct 2 ms 728 KB Output is correct
34 Correct 2 ms 728 KB Output is correct
35 Correct 2 ms 728 KB Output is correct
36 Correct 2 ms 728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 728 KB Output is correct
2 Correct 1 ms 728 KB Output is correct
3 Correct 1 ms 728 KB Output is correct
4 Correct 2 ms 728 KB Output is correct
5 Correct 1 ms 728 KB Output is correct
6 Correct 2 ms 728 KB Output is correct
7 Correct 2 ms 728 KB Output is correct
8 Correct 2 ms 728 KB Output is correct
9 Correct 2 ms 728 KB Output is correct
10 Correct 2 ms 744 KB Output is correct
11 Correct 2 ms 744 KB Output is correct
12 Correct 2 ms 744 KB Output is correct
13 Correct 2 ms 744 KB Output is correct
14 Correct 1 ms 744 KB Output is correct
15 Correct 1 ms 744 KB Output is correct
16 Correct 2 ms 744 KB Output is correct
17 Correct 1 ms 744 KB Output is correct
18 Correct 2 ms 744 KB Output is correct
19 Correct 2 ms 744 KB Output is correct
20 Correct 3 ms 744 KB Output is correct
21 Correct 3 ms 744 KB Output is correct
22 Correct 3 ms 744 KB Output is correct
23 Correct 3 ms 744 KB Output is correct
24 Correct 3 ms 744 KB Output is correct
25 Correct 3 ms 744 KB Output is correct
26 Correct 3 ms 744 KB Output is correct
27 Correct 2 ms 744 KB Output is correct
28 Correct 2 ms 744 KB Output is correct
29 Correct 2 ms 744 KB Output is correct
30 Correct 2 ms 744 KB Output is correct
31 Correct 3 ms 744 KB Output is correct
32 Correct 3 ms 744 KB Output is correct
33 Correct 3 ms 744 KB Output is correct
34 Correct 3 ms 744 KB Output is correct
35 Correct 3 ms 744 KB Output is correct
36 Correct 3 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 744 KB Output is correct
2 Correct 1 ms 744 KB Output is correct
3 Correct 2 ms 744 KB Output is correct
4 Correct 1 ms 744 KB Output is correct
5 Correct 1 ms 744 KB Output is correct
6 Correct 2 ms 744 KB Output is correct
7 Correct 2 ms 744 KB Output is correct
8 Correct 2 ms 744 KB Output is correct
9 Correct 2 ms 744 KB Output is correct
10 Correct 2 ms 744 KB Output is correct
11 Correct 2 ms 744 KB Output is correct
12 Correct 2 ms 744 KB Output is correct
13 Correct 2 ms 744 KB Output is correct
14 Correct 2 ms 744 KB Output is correct
15 Correct 2 ms 744 KB Output is correct
16 Correct 2 ms 744 KB Output is correct
17 Correct 2 ms 744 KB Output is correct
18 Correct 3 ms 744 KB Output is correct
19 Correct 3 ms 744 KB Output is correct
20 Correct 4 ms 744 KB Output is correct
21 Correct 3 ms 744 KB Output is correct
22 Correct 3 ms 744 KB Output is correct
23 Correct 3 ms 744 KB Output is correct
24 Correct 3 ms 744 KB Output is correct
25 Correct 4 ms 744 KB Output is correct
26 Correct 5 ms 744 KB Output is correct
27 Correct 6 ms 744 KB Output is correct
28 Correct 7 ms 744 KB Output is correct
29 Correct 8 ms 744 KB Output is correct
30 Correct 10 ms 744 KB Output is correct
31 Correct 7 ms 744 KB Output is correct
32 Correct 9 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 744 KB Output is correct
2 Correct 1 ms 744 KB Output is correct
3 Correct 1 ms 744 KB Output is correct
4 Correct 1 ms 744 KB Output is correct
5 Correct 2 ms 744 KB Output is correct
6 Correct 2 ms 744 KB Output is correct
7 Correct 2 ms 744 KB Output is correct
8 Correct 2 ms 744 KB Output is correct
9 Correct 2 ms 744 KB Output is correct
10 Correct 2 ms 744 KB Output is correct
11 Correct 2 ms 744 KB Output is correct
12 Correct 2 ms 744 KB Output is correct
13 Correct 2 ms 744 KB Output is correct
14 Correct 1 ms 744 KB Output is correct
15 Correct 2 ms 744 KB Output is correct
16 Correct 1 ms 744 KB Output is correct
17 Correct 2 ms 744 KB Output is correct
18 Correct 2 ms 744 KB Output is correct
19 Correct 2 ms 744 KB Output is correct
20 Correct 2 ms 744 KB Output is correct
21 Correct 3 ms 744 KB Output is correct
22 Correct 3 ms 744 KB Output is correct
23 Correct 3 ms 744 KB Output is correct
24 Correct 3 ms 744 KB Output is correct
25 Correct 3 ms 744 KB Output is correct
26 Correct 3 ms 744 KB Output is correct
27 Correct 1 ms 744 KB Output is correct
28 Correct 1 ms 744 KB Output is correct
29 Correct 1 ms 744 KB Output is correct
30 Correct 2 ms 744 KB Output is correct
31 Correct 2 ms 744 KB Output is correct
32 Correct 1 ms 744 KB Output is correct
33 Correct 2 ms 744 KB Output is correct
34 Correct 2 ms 744 KB Output is correct
35 Correct 2 ms 744 KB Output is correct
36 Correct 2 ms 744 KB Output is correct
37 Correct 2 ms 744 KB Output is correct
38 Correct 2 ms 744 KB Output is correct
39 Correct 3 ms 744 KB Output is correct
40 Correct 2 ms 744 KB Output is correct
41 Correct 3 ms 744 KB Output is correct
42 Correct 3 ms 744 KB Output is correct
43 Correct 3 ms 744 KB Output is correct
44 Correct 3 ms 744 KB Output is correct
45 Correct 3 ms 744 KB Output is correct
46 Correct 5 ms 744 KB Output is correct
47 Correct 5 ms 744 KB Output is correct
48 Correct 4 ms 744 KB Output is correct
49 Correct 5 ms 744 KB Output is correct
50 Correct 6 ms 744 KB Output is correct
51 Correct 9 ms 744 KB Output is correct
52 Correct 8 ms 744 KB Output is correct
53 Correct 8 ms 744 KB Output is correct
54 Correct 7 ms 744 KB Output is correct
55 Correct 7 ms 744 KB Output is correct
56 Correct 2 ms 744 KB Output is correct
57 Correct 5 ms 744 KB Output is correct
58 Correct 3 ms 744 KB Output is correct
59 Correct 3 ms 744 KB Output is correct
60 Correct 6 ms 748 KB Output is correct
61 Correct 2 ms 748 KB Output is correct
62 Correct 4 ms 748 KB Output is correct
63 Correct 4 ms 748 KB Output is correct
64 Correct 167 ms 748 KB Output is correct
65 Correct 5 ms 748 KB Output is correct
66 Correct 9 ms 748 KB Output is correct
67 Correct 12 ms 748 KB Output is correct
68 Correct 30 ms 748 KB Output is correct
69 Correct 21 ms 748 KB Output is correct
70 Correct 19 ms 748 KB Output is correct
71 Correct 23 ms 748 KB Output is correct
72 Correct 33 ms 748 KB Output is correct
73 Correct 33 ms 752 KB Output is correct
74 Correct 33 ms 756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 756 KB Output is correct
2 Correct 1 ms 756 KB Output is correct
3 Correct 1 ms 756 KB Output is correct
4 Correct 1 ms 756 KB Output is correct
5 Correct 2 ms 756 KB Output is correct
6 Correct 2 ms 756 KB Output is correct
7 Correct 2 ms 756 KB Output is correct
8 Correct 2 ms 756 KB Output is correct
9 Correct 2 ms 756 KB Output is correct
10 Correct 2 ms 756 KB Output is correct
11 Correct 2 ms 756 KB Output is correct
12 Correct 2 ms 756 KB Output is correct
13 Correct 2 ms 756 KB Output is correct
14 Correct 1 ms 756 KB Output is correct
15 Correct 2 ms 756 KB Output is correct
16 Correct 1 ms 756 KB Output is correct
17 Correct 1 ms 756 KB Output is correct
18 Correct 1 ms 756 KB Output is correct
19 Correct 1 ms 756 KB Output is correct
20 Correct 2 ms 756 KB Output is correct
21 Correct 2 ms 756 KB Output is correct
22 Correct 2 ms 756 KB Output is correct
23 Correct 2 ms 756 KB Output is correct
24 Correct 2 ms 756 KB Output is correct
25 Correct 2 ms 756 KB Output is correct
26 Correct 2 ms 756 KB Output is correct
27 Correct 2 ms 756 KB Output is correct
28 Correct 3 ms 756 KB Output is correct
29 Correct 3 ms 756 KB Output is correct
30 Correct 3 ms 756 KB Output is correct
31 Correct 3 ms 756 KB Output is correct
32 Correct 3 ms 756 KB Output is correct
33 Correct 5 ms 756 KB Output is correct
34 Correct 5 ms 756 KB Output is correct
35 Correct 4 ms 756 KB Output is correct
36 Correct 5 ms 756 KB Output is correct
37 Correct 7 ms 756 KB Output is correct
38 Correct 7 ms 756 KB Output is correct
39 Correct 11 ms 756 KB Output is correct
40 Correct 8 ms 756 KB Output is correct
41 Correct 8 ms 756 KB Output is correct
42 Correct 7 ms 756 KB Output is correct
43 Correct 2 ms 756 KB Output is correct
44 Correct 4 ms 756 KB Output is correct
45 Correct 2 ms 756 KB Output is correct
46 Correct 3 ms 756 KB Output is correct
47 Correct 7 ms 756 KB Output is correct
48 Correct 2 ms 756 KB Output is correct
49 Correct 4 ms 756 KB Output is correct
50 Correct 5 ms 756 KB Output is correct
51 Correct 4 ms 756 KB Output is correct
52 Correct 160 ms 756 KB Output is correct
53 Correct 43 ms 756 KB Output is correct
54 Correct 628 ms 756 KB Output is correct
55 Correct 374 ms 756 KB Output is correct
56 Correct 413 ms 756 KB Output is correct
57 Correct 271 ms 756 KB Output is correct
58 Correct 754 ms 756 KB Output is correct
59 Execution timed out 1059 ms 756 KB Time limit exceeded
60 Halted 0 ms 0 KB -