답안 #506397

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
506397 2022-01-12T03:46:19 Z mewnian Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 332 KB
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#define sze(x) (ll) x.size()
#define idx(x, a) get<x>(a)
#define LID(x) (x << 1LL)
#define RID(x) (x << 1LL) + 1LL
#define ID(x) (x + MAXN)
#define CONV(x) (x - MAXN)
#define countbit(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pi;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r)
{
    return uniform_int_distribution<ll>(l, r)(rng);
}

inline ll lcm(ll u, ll v)
{
    return u * v / __gcd(u, v);
}

const ll MAXN = 2e3 + 3;
const ll INF = 1e18;

ll dp[MAXN][MAXN], n, a, b, y[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef OFFLINE
    freopen("input.inp", "r", stdin);
    #endif
    cin >> n >> a >> b;
    for (ll i = 1; i <= n; ++i) cin >> y[i];
    for (ll i = 0; i <= n; ++i) for (ll j = 0; j <= n; ++j) dp[i][j] = LLONG_MAX;
    dp[0][0] = 0;
    for (ll i = 1; i <= n; ++i)
    {
        for (ll k = 1; k <= min(i, b); ++k)
        {
            ll sum = 0;
            for (ll l = i - 1; l >= 0; --l)
            {
                sum += y[l + 1];
                dp[i][k] = min(dp[i][k], dp[l][k - 1] | sum);
            }
//            cerr << dp[i][k] << " ";
        }
//        cerr << endl;
    }
    ll res = LLONG_MAX;
    for (ll i = a; i <= b; ++i) res = min(res, dp[n][i]);
    cout << res;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Incorrect 1 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 0 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 0 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 0 ms 328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Incorrect 1 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -