제출 #1354548

#제출 시각아이디문제언어결과실행 시간메모리
1354548idkcpBali Sculptures (APIO15_sculpture)C++20
9 / 100
48 ms452 KiB
/**
 *       author:  Vi Gia Huy
 *    Vi Gia Huy will win APIO
**/

#include <bits/stdc++.h>

using namespace std;

const long long INF = (1ll<<60);
const int N = 2e3 + 4;
int n, a, b;
long long y[N];

namespace sub1 {
    void sol() {
        long long ans = INF;

        for (int mask = 0; mask < (1 << n); mask++) {
            long long total = 0;
            long long sum = y[1];
            int cnt = 1;
            for (int i = 1; i < n; i++) {
                if ((mask >> i) & 1) {
                    total = (total | sum);
                    sum = y[i + 1];
                    cnt++;
                }
                else {
                    sum += y[i + 1];
                }
            }

            total = (total | sum);

            if (a <= cnt && cnt <= b) ans = min(ans, total);
        }

        cout << ans;

        return;
    }
}

namespace sub2 {
    void sol() {

        return;
    }
}

namespace sub3 {
    void sol() {

        return;
    }
}

namespace sub4 {
    void sol() {

        return;
    }
}

namespace sub5 {
    void sol() {

        return;
    }
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    bool checksub2 = true;
    bool checksub3 = true;

    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) {
        cin >> y[i];
        if (y[i] > 10) checksub2 = false;
        if (y[i] > 20) checksub3 = false;
    }

    if (1 <= n && n <= 20 && 1 <= a && a <= b && b <= n) sub1::sol();
    else if (1 <= n && n <= 50 && 1 <= a && a <= b && b <= min(20, n) && checksub2) sub2::sol();
    else if (1 <= n && n <= 100 && a == 1 && 1 <= b && n <= n && checksub3) sub3::sol();
    else if (1 <= n && n <= 100 && 1 <= a && a <= b && b <= n) sub4::sol();
    else if (1 <= n && n <= 2000 && a == 1 && 1 <= b && b <= n) sub5::sol();

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...