답안 #123873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123873 2019-07-02T08:24:05 Z mlyean00 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    vector<ll> y(n);
    for (int i = 0; i < n; ++i) {
        cin >> y[i];
    }

    vector<ll> y_pref(n + 1, 0);
    partial_sum(y.begin(), y.end(), y_pref.begin() + 1);

    vector<vector<ll>> dp(b + 1, vector<ll>(n + 1, LLONG_MAX));
    dp[0][0] = 0;

    for (int i = 1; i <= b; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (int k = 0; k < j; ++k) {
                if (dp[i - 1][k] == INT_MAX) continue;
                dp[i][j] =
                    min(dp[i][j], dp[i - 1][k] | (y_pref[j] - y_pref[k]));
            }
        }
    }

    ll ans = LLONG_MAX;
    for (int i = a; i <= b; ++i) {
        ans = min(ans, dp[i][n]);
    }

    cout << ans << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 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 -