답안 #168170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168170 2019-12-11T18:18:59 Z mat_v Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#define maxn 2005
#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
using namespace std;
typedef long long ll;
const ll inf = 0x3f3f3f3f;
ll niz[maxn];
ll dp[maxn][maxn];
int n;
ll pref[maxn];
ll a,b;
ll mini;
bool bio[maxn][maxn];
ll resi(int x, int y){
    if(y == 0){
        if(x == 0)return 0;
        else return inf;
    }
    if(y > x)return inf;
    if(bio[x][y])return dp[x][y];
    bio[x][y] = 1;
    dp[x][y] = inf;
    for(int i=0; i<=x - 1; i++){
        dp[x][y] = min(dp[x][y], resi(i,y - 1) | (pref[x] - pref[i]));
    }
    return dp[x][y];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> a >> b;
    for(int i=1; i<=n; i++)cin >> niz[i];
    pref[0] = 0;
    for(int i=1; i<=n; i++)pref[i] = pref[i - 1] + niz[i];
    mini = resi(n,a);
    for(int i=a; i<=b; i++)mini = min(mini, resi(n,i));
    cout << mini << endl;
    return 0;
    //if(1){
        for(int i=1;i <=n; i++){
            dp[0][i] = inf;
        }
        for(int i=1; i<=n; i++){
            dp[i][0] = inf;
        }
        dp[0][0] = 0;
        for(int i=1; i<=n; i++){
            for(int j=1; j<=b; j++){
                dp[i][j] = inf;
                if(j > i)continue;
                for(int k=0; k<=i - 1; k++){
                    dp[i][j] = min((dp[k][j - 1] | (pref[i] - pref[k])), dp[i][j]);
                }
            }
        }
        for(int i=a; i<=b; i++)mini = min(mini, dp[n][i]);
        cout << mini << endl;
        return 0;
    //}
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -