답안 #1084733

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1084733 2024-09-06T19:10:13 Z MrPavlito Bali Sculptures (APIO15_sculpture) C++17
0 / 100
18 ms 31908 KB
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
#define endl "\n"
#define pii pair<int,int>

using namespace std;

const int MAXN = 2e3+5;
const int mod7 = 1e9+7;
const long long inf = 1e18;

vector<vector<int>> dp(MAXN, vector<int>(MAXN, inf));




signed main()
{
    ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0);
    int tt=1;
    //cin >> tt;
    while(tt--)
    {
        int n,a,b;
        cin >> n >> a >> b;
        vector<int>niz(n);
        vector<int>pref(n+1, 0);
        for(int i=0; i<n; i++)
        {
            cin >> niz[i];
            pref[i+1] = pref[i] + niz[i];
        }
        for(int i=0; i<n; i++)dp[1][i] = pref[i+1];
        for(int i=2; i<=b; i++)
        {
            for(int j=i-1; j<n; j++)
            {
                for(int k=i-1; k<j; k++)
                {
                    dp[i][j] = min(dp[i][j], dp[i-1][k]| (pref[j+1]- pref[k+1]));
                }
            }
        }
        /*for(int i=1; i<=b; i++)
        {
            for(int j=0; j<n; j++)cout << dp[i][j] << " ";cout << endl;
        }
        */
        int rez = inf;
        for(int i=a; i<=b; i++)rez = min(rez, dp[i][n-1]);
        cout << rez << endl;



    }
}

/*
6 1 3
8 1 2 1 5 4
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 31832 KB Output is correct
2 Incorrect 14 ms 31832 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 31836 KB Output is correct
2 Incorrect 14 ms 31852 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 31832 KB Output is correct
2 Incorrect 14 ms 31852 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 31832 KB Output is correct
2 Incorrect 16 ms 31836 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 31836 KB Output is correct
2 Incorrect 18 ms 31908 KB Output isn't correct
3 Halted 0 ms 0 KB -