Submission #1084734

# Submission time Handle Problem Language Result Execution time Memory
1084734 2024-09-06T19:11:59 Z MrPavlito Bali Sculptures (APIO15_sculpture) C++17
0 / 100
22 ms 31964 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-2; 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
*/
# Verdict Execution time Memory Grader output
1 Correct 18 ms 31832 KB Output is correct
2 Incorrect 19 ms 31836 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 31800 KB Output is correct
2 Incorrect 13 ms 31964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 31836 KB Output is correct
2 Incorrect 14 ms 31876 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 31808 KB Output is correct
2 Incorrect 16 ms 31864 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 31836 KB Output is correct
2 Incorrect 14 ms 31836 KB Output isn't correct
3 Halted 0 ms 0 KB -