답안 #551001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
551001 2022-04-19T17:31:05 Z ala2 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
8 ms 9988 KB
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
int n,l,r;
int a[1001000];
int p[1000100];
int suf[1001000];
int dp[55][22][501];
int sum(int i,int j)
{
    return p[j]-p[i]+a[i];
}
int f(int i,int k,int x)
{
    if(k==r)
    {
        return (x|suf[i]);
    }
    if(i==n-1)
        return (x|a[i]);
    if(dp[i][k][x]!=-1)
        return dp[i][k][x];
    int mn=1e17;
    if(k>=l)
        mn=min(mn,(suf[i]|x));
    for(int j=i;j<n-1;j++)
    {
        mn=min(mn,f(j+1,k+1,(x|sum(i,j))));

    }
    return dp[i][k][x]=mn;

}
signed main()
{
     memset(dp,-1,sizeof dp);
    cin>>n>>l>>r;
    l--;
    r--;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=a[0];
    for(int i=1;i<n;i++)
        p[i]=p[i-1]+a[i];
    suf[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--)
    {
        suf[i]=suf[i+1]+a[i];
    }
    cout<<f(0,0,0)<<endl;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 5076 KB Output is correct
3 Correct 3 ms 5076 KB Output is correct
4 Correct 2 ms 5076 KB Output is correct
5 Correct 3 ms 5076 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 5076 KB Output is correct
8 Correct 2 ms 5076 KB Output is correct
9 Correct 3 ms 5044 KB Output is correct
10 Correct 2 ms 5076 KB Output is correct
11 Correct 2 ms 5076 KB Output is correct
12 Correct 2 ms 4948 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
14 Correct 2 ms 5076 KB Output is correct
15 Incorrect 3 ms 4952 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5076 KB Output is correct
2 Correct 3 ms 5076 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 5076 KB Output is correct
6 Correct 2 ms 5076 KB Output is correct
7 Correct 2 ms 5076 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 2 ms 5076 KB Output is correct
10 Correct 3 ms 5076 KB Output is correct
11 Correct 3 ms 5020 KB Output is correct
12 Correct 3 ms 5016 KB Output is correct
13 Correct 2 ms 5076 KB Output is correct
14 Correct 2 ms 5076 KB Output is correct
15 Incorrect 4 ms 4948 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5076 KB Output is correct
2 Correct 4 ms 4948 KB Output is correct
3 Correct 3 ms 5076 KB Output is correct
4 Correct 2 ms 5076 KB Output is correct
5 Correct 3 ms 5076 KB Output is correct
6 Correct 2 ms 5076 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 2 ms 5076 KB Output is correct
9 Correct 2 ms 5076 KB Output is correct
10 Correct 2 ms 4948 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 3 ms 5076 KB Output is correct
13 Correct 3 ms 5076 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 2 ms 5076 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 4 ms 5076 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 2 ms 5076 KB Output is correct
21 Correct 4 ms 4948 KB Output is correct
22 Correct 4 ms 5056 KB Output is correct
23 Correct 3 ms 5076 KB Output is correct
24 Correct 5 ms 5076 KB Output is correct
25 Incorrect 6 ms 5076 KB Output isn't correct
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5076 KB Output is correct
2 Correct 4 ms 5076 KB Output is correct
3 Correct 2 ms 5076 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 2 ms 5076 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 5076 KB Output is correct
10 Correct 2 ms 4948 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 2 ms 4948 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Incorrect 3 ms 5076 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5076 KB Output is correct
2 Correct 3 ms 5076 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 5076 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 5076 KB Output is correct
8 Correct 3 ms 5076 KB Output is correct
9 Correct 3 ms 4984 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 2 ms 5076 KB Output is correct
12 Correct 4 ms 5076 KB Output is correct
13 Correct 3 ms 5076 KB Output is correct
14 Runtime error 8 ms 9988 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -