45012023-03-29 10:59:57ZsofiaKeresztelyDinamitcpp14Accepted 50/5026ms5324 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<ll> > t(n+1, vector<ll>(m+1, 0));
    vector<vector<vector<ll> > > dp(n+1, vector<vector<ll> >(m+1, vector<ll>(k+1, INT_MAX/2)));
    for (int i=1; i<=n; i++){
        for (int j=1; j<=m; j++){
            cin >> t[i][j];
        }
    }
    dp[1][1][0] = t[1][1];
    for (int i=1; i<=k; i++){
        dp[1][1][i] = dp[1][1][i-1] / 2;
    }
    for (int i=1; i<=n; i++){
        for (int j=1; j<=m; j++){
            for (int l=0; l<=k; l++){
                for (int x=0; x<=l; x++){
                    dp[i][j][l] = min(dp[i][j][l], t[i][j]/(1 << x)+min(dp[i][j-1][l-x], dp[i-1][j][l-x]));
                }
            }
        }
    }
    cout << dp[n][m][k];
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1688 KiB
2Accepted0/026ms3072 KiB
3Accepted2/23ms2300 KiB
4Accepted2/23ms2556 KiB
5Accepted3/33ms2772 KiB
6Accepted3/33ms2984 KiB
7Accepted2/225ms4236 KiB
8Accepted3/326ms4540 KiB
9Accepted2/24ms3652 KiB
10Accepted2/24ms3636 KiB
11Accepted3/34ms3644 KiB
12Accepted3/34ms3660 KiB
13Accepted2/28ms4104 KiB
14Accepted3/38ms4308 KiB
15Accepted2/226ms5200 KiB
16Accepted3/326ms5136 KiB
17Accepted2/226ms5144 KiB
18Accepted3/326ms5144 KiB
19Accepted2/226ms5148 KiB
20Accepted3/326ms5304 KiB
21Accepted2/226ms5324 KiB
22Accepted3/326ms5320 KiB