답안 #778682

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
778682 2023-07-10T14:52:41 Z benjaminkleyn Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 324 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));
    k--;
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -