204992026-01-07 13:01:02szabelrFestés (50 pont)cpp17Wrong answer 0/50277ms30908 KiB
// Festés_clean.c=pp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <climits>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<int>sorar(n);
    for (int i = 0; i < n; i++)
    {
        int x; cin >> x;
        sorar[i] = x;
    }
    cout << "yo";
    vector<vector<vector<int>>> ar(m+1, vector<vector<int>>(n + 1, vector<int>(n+1)));
    //m,kezdet,veg
    for (int i = 1; i <= m; i++)
    {
        for (int y = 1; y <= n; y++)
        {
            for (int z = y; z <= n; z++)
            {
                int x; cin >> x;
                ar[i][y][z] = x;
            }
        }
    }
    int best_sum = INT_MAX;
    for (int bitmask = 0; bitmask <= (1 << n)-1; bitmask++)
    {
        int sum = 0;
        for (int j = 0; j <= n - 1; j++)
        {
            if ((bitmask & (1 << j)) != 0)
                sum += sorar[j];
        }
        for (int i = 1; i <= m; i++)
        {
            vector<long long>dp(n + 1, INT_MAX);
            dp[0]=0;
            for (int y = 1; y <= n; y++) {
                if ((bitmask & (1 << (y - 1))) != 0) {
                    dp[y] = min(dp[y], dp[y - 1]);
                }
                for (int z = 1; z <= y; z++) {
                    if (ar[i][z][y] != INT_MAX) { // ha van ilyen ajánlat
                        dp[y] = min(dp[y], dp[z - 1] + ar[i][z][y]);
                    }
                }
            }
            sum += dp[n];
        }
        best_sum = min(best_sum, sum);
    }
    cout << best_sum;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/2164ms26164 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/34ms756 KiB
6Wrong answer0/225ms3388 KiB
7Wrong answer0/2252ms30816 KiB
8Wrong answer0/2254ms30836 KiB
9Wrong answer0/2270ms30908 KiB
10Wrong answer0/2270ms30772 KiB
11Wrong answer0/2250ms30772 KiB
12Wrong answer0/2231ms28212 KiB
13Wrong answer0/2256ms28212 KiB
14Wrong answer0/290ms19832 KiB
15Wrong answer0/386ms19760 KiB
16Wrong answer0/3149ms26156 KiB
17Wrong answer0/2158ms26116 KiB
18Wrong answer0/3158ms26156 KiB
19Wrong answer0/2225ms27712 KiB
20Wrong answer0/2240ms29240 KiB
21Wrong answer0/2266ms30516 KiB
22Wrong answer0/2270ms30744 KiB
23Wrong answer0/2252ms30772 KiB
24Wrong answer0/2252ms30768 KiB
25Wrong answer0/2277ms30856 KiB