Submission #778684

# Submission time Handle Problem Language Result Execution time Memory
778684 2023-07-10T14:56:02 Z benjaminkleyn Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 212 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma,bmi,bmi2")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, A, B;
ll x[2000];

int k = 0;
ll y[2000];
ll search(int i = 0)
{
    if (i == n)
    {
        if (k < A || B < k)
            return LLONG_MAX;
        ll ans = 0;
        for (int j = 0; j < k; j++)
            ans |= y[j];
        return ans;
    }

    ll ans = LLONG_MAX;
    for (int j = 0; j < k; j++)
    {
        y[j] += x[i];
        ans = min(ans, search(i + 1));
        y[j] -= x[i];
    }
    y[k++] = x[i];
    ans = min(ans, search(i + 1));
    y[--k] = 0;
    return ans;
}

int main()
{
    cin.tie(0)->sync_with_stdio(0);

    cin >> n >> A >> B;
    for (int i = 0; i < n; i++)
        cin >> x[i];
    if (n > 20) return 1;

    sort(x, x + n);
    cout << search() << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -