Submission #131288

# Submission time Handle Problem Language Result Execution time Memory
131288 2019-07-17T00:44:46 Z mlyean00 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 380 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> pref(n + 1, 0);
    partial_sum(y.begin(), y.end(), pref.begin() + 1);

    vector<set<ll>> v1(n);
    v1[0].insert(0);

    ll ans = LLONG_MAX;
    for (int i = 0; i < b; ++i) {
        vector<set<ll>> v2(n);
        for (int j = 0; j < n; ++j) {
            for (ll val : v1[j]) {
                for (int h = j + 1; h < n; ++h) {
                    v2[h].insert(val | pref[h] - pref[j]);
                }
                if (i > a) ans = min(ans, val | (pref[n] - pref[j]));
            }
        }
        swap(v1, v2);
    }

    cout << ans << endl;

    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:26:48: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
                     v2[h].insert(val | pref[h] - pref[j]);
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 292 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 252 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 380 KB Output isn't correct
4 Halted 0 ms 0 KB -