8572022-01-21 09:52:56kicsiboglarDinamitcpp11Accepted 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;

}

SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1744 KiB
2Accepted0/092ms2760 KiB
3Accepted2/22ms1960 KiB
4Accepted2/22ms1972 KiB
5Accepted3/32ms1988 KiB
6Accepted3/32ms2000 KiB
7Accepted2/292ms2796 KiB
8Accepted3/3103ms2768 KiB
9Accepted2/210ms1980 KiB
10Accepted2/28ms1984 KiB
11Accepted3/37ms1984 KiB
12Accepted3/37ms1988 KiB
13Accepted2/224ms2244 KiB
14Accepted3/324ms2248 KiB
15Accepted2/292ms2808 KiB
16Accepted3/3100ms2820 KiB
17Accepted2/293ms2828 KiB
18Accepted3/393ms2840 KiB
19Accepted2/290ms2852 KiB
20Accepted3/393ms2864 KiB
21Accepted2/2104ms2876 KiB
22Accepted3/393ms2888 KiB