답안 #112131

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
112131 2019-05-17T14:43:17 Z Runtime_error_ Bali Sculptures (APIO15_sculpture) C++14
0 / 100
5 ms 3712 KB
#include <bits/stdc++.h>
using namespace std;
const int N=105,O=(1<<13)+9,MX=1e9+9;
int n,x,y,a[N],pre[N],dp[N][O];

int solve(int pos,int OR){

    if(pos==n+1)
        return 0;

    int &ret=dp[pos][OR];
    if(ret!=-1)
        return ret;
    ret=MX;
    for(int i=pos;i<=n;i++)
        if( (OR & (pre[i]-pre[pos-1]))==0  )
            ret=min(ret,solve(i+1,OR)+1);
    return ret;
}

int opposite(int num){

    int ret=0;
    for(int i=0;i<=11;i++)
        if( (num&(1<<i))==0 )
            ret|=(1<<i);
    return ret;
}

int main(){

    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
        cin>>a[i],pre[i]=a[i]+pre[i-1];

    memset(dp,-1,sizeof(dp));
    for(int i=1;i<(1<<12);i++)
        if(solve(1,opposite(i))<=y)
            cout<<i<<endl,exit(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3712 KB Output is correct
2 Correct 4 ms 3712 KB Output is correct
3 Incorrect 4 ms 3712 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3712 KB Output is correct
2 Correct 4 ms 3712 KB Output is correct
3 Incorrect 4 ms 3712 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3712 KB Output is correct
2 Correct 4 ms 3712 KB Output is correct
3 Incorrect 4 ms 3712 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3712 KB Output is correct
2 Correct 5 ms 3712 KB Output is correct
3 Incorrect 5 ms 3712 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3712 KB Output is correct
2 Correct 4 ms 3712 KB Output is correct
3 Incorrect 4 ms 3712 KB Output isn't correct
4 Halted 0 ms 0 KB -