답안 #41849

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41849 2018-02-21T15:16:03 Z XmtosX Bali Sculptures (APIO15_sculpture) C++14
21 / 100
1000 ms 1684 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;
        }
        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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 572 KB Output is correct
5 Correct 2 ms 576 KB Output is correct
6 Correct 2 ms 708 KB Output is correct
7 Correct 2 ms 708 KB Output is correct
8 Correct 2 ms 708 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Correct 2 ms 708 KB Output is correct
11 Correct 2 ms 708 KB Output is correct
12 Correct 3 ms 708 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Incorrect 2 ms 860 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 2 ms 912 KB Output is correct
9 Correct 2 ms 912 KB Output is correct
10 Correct 2 ms 912 KB Output is correct
11 Correct 2 ms 912 KB Output is correct
12 Correct 2 ms 912 KB Output is correct
13 Correct 2 ms 912 KB Output is correct
14 Incorrect 2 ms 912 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 912 KB Output is correct
2 Correct 2 ms 912 KB Output is correct
3 Correct 2 ms 912 KB Output is correct
4 Correct 2 ms 912 KB Output is correct
5 Correct 2 ms 912 KB Output is correct
6 Correct 2 ms 912 KB Output is correct
7 Correct 2 ms 912 KB Output is correct
8 Correct 2 ms 912 KB Output is correct
9 Correct 2 ms 912 KB Output is correct
10 Correct 2 ms 912 KB Output is correct
11 Correct 2 ms 912 KB Output is correct
12 Correct 2 ms 912 KB Output is correct
13 Correct 2 ms 912 KB Output is correct
14 Correct 2 ms 912 KB Output is correct
15 Correct 2 ms 912 KB Output is correct
16 Correct 3 ms 912 KB Output is correct
17 Correct 3 ms 912 KB Output is correct
18 Correct 3 ms 912 KB Output is correct
19 Correct 4 ms 912 KB Output is correct
20 Correct 3 ms 912 KB Output is correct
21 Correct 3 ms 912 KB Output is correct
22 Correct 4 ms 916 KB Output is correct
23 Correct 3 ms 920 KB Output is correct
24 Correct 3 ms 1036 KB Output is correct
25 Correct 4 ms 1036 KB Output is correct
26 Correct 6 ms 1036 KB Output is correct
27 Correct 7 ms 1036 KB Output is correct
28 Correct 8 ms 1036 KB Output is correct
29 Correct 9 ms 1036 KB Output is correct
30 Correct 9 ms 1036 KB Output is correct
31 Correct 8 ms 1036 KB Output is correct
32 Correct 8 ms 1036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1036 KB Output is correct
2 Correct 2 ms 1036 KB Output is correct
3 Correct 2 ms 1036 KB Output is correct
4 Correct 2 ms 1084 KB Output is correct
5 Correct 2 ms 1084 KB Output is correct
6 Correct 2 ms 1084 KB Output is correct
7 Correct 2 ms 1084 KB Output is correct
8 Correct 2 ms 1084 KB Output is correct
9 Correct 2 ms 1084 KB Output is correct
10 Correct 2 ms 1084 KB Output is correct
11 Correct 2 ms 1084 KB Output is correct
12 Correct 2 ms 1084 KB Output is correct
13 Correct 2 ms 1084 KB Output is correct
14 Incorrect 2 ms 1084 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1084 KB Output is correct
2 Correct 2 ms 1084 KB Output is correct
3 Correct 2 ms 1084 KB Output is correct
4 Correct 2 ms 1084 KB Output is correct
5 Correct 2 ms 1084 KB Output is correct
6 Correct 2 ms 1084 KB Output is correct
7 Correct 2 ms 1084 KB Output is correct
8 Correct 2 ms 1084 KB Output is correct
9 Correct 2 ms 1084 KB Output is correct
10 Correct 2 ms 1084 KB Output is correct
11 Correct 2 ms 1084 KB Output is correct
12 Correct 2 ms 1084 KB Output is correct
13 Correct 2 ms 1084 KB Output is correct
14 Correct 2 ms 1084 KB Output is correct
15 Correct 2 ms 1116 KB Output is correct
16 Correct 2 ms 1120 KB Output is correct
17 Correct 2 ms 1124 KB Output is correct
18 Correct 2 ms 1128 KB Output is correct
19 Correct 2 ms 1132 KB Output is correct
20 Correct 2 ms 1136 KB Output is correct
21 Correct 2 ms 1140 KB Output is correct
22 Correct 2 ms 1252 KB Output is correct
23 Correct 2 ms 1252 KB Output is correct
24 Correct 2 ms 1252 KB Output is correct
25 Correct 2 ms 1252 KB Output is correct
26 Correct 3 ms 1252 KB Output is correct
27 Correct 3 ms 1252 KB Output is correct
28 Correct 4 ms 1252 KB Output is correct
29 Correct 3 ms 1252 KB Output is correct
30 Correct 3 ms 1252 KB Output is correct
31 Correct 5 ms 1252 KB Output is correct
32 Correct 3 ms 1252 KB Output is correct
33 Correct 3 ms 1252 KB Output is correct
34 Correct 3 ms 1296 KB Output is correct
35 Correct 4 ms 1296 KB Output is correct
36 Correct 6 ms 1296 KB Output is correct
37 Correct 7 ms 1296 KB Output is correct
38 Correct 7 ms 1308 KB Output is correct
39 Correct 8 ms 1308 KB Output is correct
40 Correct 9 ms 1308 KB Output is correct
41 Correct 8 ms 1308 KB Output is correct
42 Correct 8 ms 1308 KB Output is correct
43 Correct 2 ms 1356 KB Output is correct
44 Correct 4 ms 1356 KB Output is correct
45 Correct 3 ms 1356 KB Output is correct
46 Correct 3 ms 1356 KB Output is correct
47 Correct 8 ms 1356 KB Output is correct
48 Correct 3 ms 1356 KB Output is correct
49 Correct 5 ms 1356 KB Output is correct
50 Correct 5 ms 1356 KB Output is correct
51 Correct 4 ms 1356 KB Output is correct
52 Correct 153 ms 1428 KB Output is correct
53 Correct 43 ms 1428 KB Output is correct
54 Correct 626 ms 1428 KB Output is correct
55 Correct 353 ms 1472 KB Output is correct
56 Correct 414 ms 1628 KB Output is correct
57 Correct 258 ms 1648 KB Output is correct
58 Correct 700 ms 1684 KB Output is correct
59 Execution timed out 1072 ms 1684 KB Time limit exceeded
60 Halted 0 ms 0 KB -