제출 #284408

#제출 시각아이디문제언어결과실행 시간메모리
284408dooweyBali Sculptures (APIO15_sculpture)C++14
100 / 100
109 ms512 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 2005;
int dp[N][2];
ll A[N];
int main(){
    fastIO;
    int n, a, b;
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i ++ ){
        cin >> A[i];
    }
    ll xf = 0;
    ll nw;
    ll sigma;
    ll answ = 0;
    bool res;
    for(int lg = 40; lg >= 0; lg -- ){
        nw = xf;
        nw |= (1ll << lg);
        for(int i = 0; i <= n; i ++ ){
            dp[i][0]=(int)1e9;
            dp[i][1]=-(int)1e9;
        }
        dp[0][0]=0;
        dp[0][1]=0;
        for(int i = 1; i <= n; i ++ ){
            sigma = 0;
            for(int j = i; j > 0; j -- ){
                sigma += A[j];
                if((sigma & nw)) continue;
                dp[i][0]=min(dp[i][0],dp[j-1][0]+1);
                dp[i][1]=max(dp[i][1],dp[j-1][1]+1);
            }
        }
        if(dp[n][0] > b || dp[n][1] < a){
            answ |= (1ll << lg);
        }
        else{
            xf = nw;
        }
    }
    cout << answ << "\n";
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

sculpture.cpp: In function 'int main()':
sculpture.cpp:27:10: warning: unused variable 'res' [-Wunused-variable]
   27 |     bool res;
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...