답안 #482660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
482660 2021-10-26T02:40:24 Z jalsol Bali Sculptures (APIO15_sculpture) C++17
21 / 100
435 ms 31888 KB
#ifdef LOCAL
#include "local.h"
#else
#include <bits/stdc++.h>
#define debug(...)
#define DB(...)
#endif

using namespace std;

const bool __initialization = []() {
    cin.tie(nullptr)->sync_with_stdio(false);
#define TASK "empty"
    if (fopen(TASK".inp", "r")) {
        (void)(!freopen(TASK".inp", "r", stdin));
        (void)(!freopen(TASK".out", "w", stdout)); }
    cout << setprecision(12) << fixed;
    return true;
}();

using ll = long long;
using ld = long double;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

#define For(i, l, r) for (int i = (l); i <= (r); ++i)
#define Ford(i, r, l) for (int i = (r); i >= (l); --i)
#define Rep(i, n) For (i, 0, (n) - 1)
#define Repd(i, n) Ford (i, (n) - 1, 0)
#define Fe(...) for (auto __VA_ARGS__)

template <class C> inline int isz(const C& c) { return static_cast<int>(c.size()); }
template <class T> inline bool chmin(T& a, const T& b) { return (a > b) ? a = b, true : false; }
template <class T> inline bool chmax(T& a, const T& b) { return (a < b) ? a = b, true : false; }

constexpr ld eps = 1e-9;
constexpr int inf = 1e9;
constexpr ll linf = 1e18;

// =============================================================================

constexpr int maxn = 2000 + 5;

int n, lo, hi;
int a[maxn];
ll pref[maxn];

ll dp[maxn][maxn];

ll go(int i, int rem) {
    if (i == n + 1) return rem == 0 ? 0 : linf;
    if (rem == 0) return linf;

    ll& ret = dp[i][rem];
    if (ret != -1) return ret;

    ret = linf;

    For (j, i, n) {
        chmin(ret, go(j + 1, rem - 1) | (pref[j] - pref[i - 1]));
    }

    return ret;
}

signed main() {
    cin >> n >> lo >> hi;
    For (i, 1, n) cin >> a[i];

    For (i, 1, n) {
        pref[i] = pref[i - 1] + a[i];
    }

    ll ans = inf;

    For (i, lo, hi) {
        memset(dp, -1, sizeof(dp));
        chmin(ans, go(1, i));
    }

    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 31812 KB Output is correct
2 Correct 25 ms 31692 KB Output is correct
3 Correct 13 ms 31692 KB Output is correct
4 Correct 19 ms 31788 KB Output is correct
5 Correct 13 ms 31672 KB Output is correct
6 Correct 63 ms 31692 KB Output is correct
7 Correct 19 ms 31756 KB Output is correct
8 Correct 20 ms 31692 KB Output is correct
9 Correct 19 ms 31796 KB Output is correct
10 Correct 21 ms 31700 KB Output is correct
11 Correct 13 ms 31692 KB Output is correct
12 Correct 20 ms 31692 KB Output is correct
13 Correct 73 ms 31700 KB Output is correct
14 Correct 16 ms 31692 KB Output is correct
15 Correct 14 ms 31708 KB Output is correct
16 Correct 26 ms 31792 KB Output is correct
17 Correct 16 ms 31692 KB Output is correct
18 Correct 19 ms 31684 KB Output is correct
19 Correct 13 ms 31772 KB Output is correct
20 Correct 14 ms 31792 KB Output is correct
21 Incorrect 24 ms 31692 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 31692 KB Output is correct
2 Correct 22 ms 31768 KB Output is correct
3 Correct 14 ms 31692 KB Output is correct
4 Correct 20 ms 31764 KB Output is correct
5 Correct 13 ms 31772 KB Output is correct
6 Correct 63 ms 31776 KB Output is correct
7 Correct 20 ms 31692 KB Output is correct
8 Correct 21 ms 31800 KB Output is correct
9 Correct 21 ms 31772 KB Output is correct
10 Correct 21 ms 31800 KB Output is correct
11 Correct 15 ms 31792 KB Output is correct
12 Correct 20 ms 31796 KB Output is correct
13 Correct 67 ms 31692 KB Output is correct
14 Correct 18 ms 31788 KB Output is correct
15 Correct 12 ms 31692 KB Output is correct
16 Correct 24 ms 31788 KB Output is correct
17 Correct 16 ms 31768 KB Output is correct
18 Correct 20 ms 31692 KB Output is correct
19 Correct 13 ms 31692 KB Output is correct
20 Correct 12 ms 31692 KB Output is correct
21 Incorrect 24 ms 31700 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 31692 KB Output is correct
2 Correct 22 ms 31692 KB Output is correct
3 Correct 12 ms 31692 KB Output is correct
4 Correct 19 ms 31732 KB Output is correct
5 Correct 16 ms 31692 KB Output is correct
6 Correct 65 ms 31684 KB Output is correct
7 Correct 20 ms 31692 KB Output is correct
8 Correct 20 ms 31788 KB Output is correct
9 Correct 21 ms 31792 KB Output is correct
10 Correct 19 ms 31692 KB Output is correct
11 Correct 14 ms 31784 KB Output is correct
12 Correct 20 ms 31800 KB Output is correct
13 Correct 70 ms 31692 KB Output is correct
14 Correct 80 ms 31692 KB Output is correct
15 Correct 46 ms 31724 KB Output is correct
16 Correct 30 ms 31736 KB Output is correct
17 Correct 76 ms 31692 KB Output is correct
18 Correct 81 ms 31688 KB Output is correct
19 Correct 80 ms 31692 KB Output is correct
20 Correct 14 ms 31760 KB Output is correct
21 Correct 81 ms 31772 KB Output is correct
22 Correct 72 ms 31692 KB Output is correct
23 Correct 46 ms 31888 KB Output is correct
24 Correct 87 ms 31776 KB Output is correct
25 Correct 45 ms 31712 KB Output is correct
26 Correct 101 ms 31692 KB Output is correct
27 Correct 222 ms 31692 KB Output is correct
28 Correct 435 ms 31772 KB Output is correct
29 Correct 412 ms 31692 KB Output is correct
30 Correct 14 ms 31692 KB Output is correct
31 Correct 204 ms 31820 KB Output is correct
32 Correct 318 ms 31780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 31692 KB Output is correct
2 Correct 24 ms 31700 KB Output is correct
3 Correct 14 ms 31692 KB Output is correct
4 Correct 20 ms 31788 KB Output is correct
5 Correct 13 ms 31716 KB Output is correct
6 Correct 66 ms 31780 KB Output is correct
7 Correct 19 ms 31692 KB Output is correct
8 Correct 19 ms 31692 KB Output is correct
9 Correct 21 ms 31772 KB Output is correct
10 Correct 21 ms 31716 KB Output is correct
11 Correct 14 ms 31692 KB Output is correct
12 Correct 21 ms 31692 KB Output is correct
13 Correct 67 ms 31780 KB Output is correct
14 Correct 16 ms 31692 KB Output is correct
15 Correct 12 ms 31744 KB Output is correct
16 Correct 23 ms 31776 KB Output is correct
17 Correct 17 ms 31680 KB Output is correct
18 Correct 23 ms 31692 KB Output is correct
19 Correct 13 ms 31744 KB Output is correct
20 Correct 13 ms 31692 KB Output is correct
21 Incorrect 26 ms 31692 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 31680 KB Output is correct
2 Correct 27 ms 31796 KB Output is correct
3 Correct 12 ms 31700 KB Output is correct
4 Correct 20 ms 31692 KB Output is correct
5 Correct 13 ms 31692 KB Output is correct
6 Correct 64 ms 31692 KB Output is correct
7 Correct 20 ms 31692 KB Output is correct
8 Correct 20 ms 31692 KB Output is correct
9 Correct 19 ms 31692 KB Output is correct
10 Correct 20 ms 31692 KB Output is correct
11 Correct 14 ms 31692 KB Output is correct
12 Correct 21 ms 31692 KB Output is correct
13 Correct 69 ms 31792 KB Output is correct
14 Incorrect 20 ms 31692 KB Output isn't correct
15 Halted 0 ms 0 KB -