8572022-01-21 09:52:56kicsiboglarDinamitcpp11Elfogadva 50/50104ms2888 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#define ll long long 

using namespace std;

ll n, m, i, j, k, l, p, o;

int main()
{
    cin >> n >> m >> k;
 
    vector <vector<ll> > terkep(n+1, vector<ll>(m+1, INT_MAX));
    for (i = 1; i <= n; ++ i)
    {
        for (j = 1; j <= m; ++j) cin >> terkep[i][j];
    }

    vector <vector<vector<ll> > > mini(n + 1, vector<vector<ll> >(m + 1, vector<ll>(k + 1, INT_MAX)));
    ll actut = 0;
    mini[1][0][0] = 0;
    for (i = 1; i <= n; ++i)
    {
        for (j = 1; j <= m; ++j)
        {
            for (o = 0; o <= k; ++o)
            {
                for (p = 0; p <= k - o; ++p)
                {
                    actut = min(mini[i - 1][j][o] + terkep[i][j] / pow(2, p), mini[i][j - 1][o] + terkep[i][j] / pow(2, p));
                    mini[i][j][o + p] = min(mini[i][j][o + p], actut);
                }
            }
        }
    }
    cout << mini[n][m][k];
    return 0;

}

RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/02ms1744 KiB
2Elfogadva0/092ms2760 KiB
3Elfogadva2/22ms1960 KiB
4Elfogadva2/22ms1972 KiB
5Elfogadva3/32ms1988 KiB
6Elfogadva3/32ms2000 KiB
7Elfogadva2/292ms2796 KiB
8Elfogadva3/3103ms2768 KiB
9Elfogadva2/210ms1980 KiB
10Elfogadva2/28ms1984 KiB
11Elfogadva3/37ms1984 KiB
12Elfogadva3/37ms1988 KiB
13Elfogadva2/224ms2244 KiB
14Elfogadva3/324ms2248 KiB
15Elfogadva2/292ms2808 KiB
16Elfogadva3/3100ms2820 KiB
17Elfogadva2/293ms2828 KiB
18Elfogadva3/393ms2840 KiB
19Elfogadva2/290ms2852 KiB
20Elfogadva3/393ms2864 KiB
21Elfogadva2/2104ms2876 KiB
22Elfogadva3/393ms2888 KiB