답안 #145978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145978 2019-08-21T13:33:38 Z mhy908 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
3 ms 376 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n, a, b;
LL arr[2010], sum[2010];
int dp[2010];
bool poss(LL num)
{
    for(int i=1; i<=n; i++){
        dp[i]=i;
        for(int j=1; j<=i; j++){
            LL t=sum[i]-sum[j-1];
            if((t&(~num))==0){
                dp[i]=min(dp[i], dp[j-1]+1);
            }
        }
    }
    if(dp[n]>b)return false;
    return true;
}
int main()
{
    scanf("%d %d %d", &n, &a, &b);
    for(int i=1; i<=n; i++){
        scanf("%lld", &arr[i]);
        sum[i]=sum[i-1]+arr[i];
    }
    LL ans=(1LL<<50)-1;
    for(int i=49; i>=0; i--){
        LL temp=(1LL<<i);
        if(poss(ans&(~temp)))ans&=(~temp);
    }
    printf("%lld", ans);
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 356 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -