제출 #248978

#제출 시각아이디문제언어결과실행 시간메모리
248978rocks03Bali Sculptures (APIO15_sculpture)C++14
21 / 100
23 ms34944 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 2e3+100;
int N, A, B;
ll a[MAXN], DP[MAXN+1][MAXN+1];

ll f(int pos, int gruppo){
    if(pos == N){
        if(gruppo < A || gruppo > B)
            return LLONG_MAX;
        return 0;
    }
    if(DP[pos][gruppo] != -1) return DP[pos][gruppo];
    ll sum = 0, best = LLONG_MAX, res;
    for(int i = pos; i < N; i++){
        sum += a[i];
        res = f(i+1, gruppo+1);
        best = min(best, (sum|res));
    }
    return DP[pos][gruppo] = best;
}

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> A >> B;
    for(int i = 0; i < N; i++) cin >> a[i];
    memset(DP, -1, sizeof(DP));
    cout << f(0, 0);
}

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

sculpture.cpp:30:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#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...