45022023-03-29 11:02:31ZsofiaKeresztelyDinamitcpp14Accepted 50/509ms4728 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int> > t(n+1, vector<int>(m+1, 0));
    vector<vector<vector<int> > > dp(n+1, vector<vector<int> >(m+1, vector<int>(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/03ms1812 KiB
2Accepted0/09ms2568 KiB
3Accepted2/23ms2444 KiB
4Accepted2/23ms2660 KiB
5Accepted3/33ms2872 KiB
6Accepted3/33ms3084 KiB
7Accepted2/29ms3676 KiB
8Accepted3/39ms3640 KiB
9Accepted2/23ms3332 KiB
10Accepted2/23ms3404 KiB
11Accepted3/33ms3528 KiB
12Accepted3/33ms3608 KiB
13Accepted2/24ms3676 KiB
14Accepted3/34ms3932 KiB
15Accepted2/29ms4232 KiB
16Accepted3/39ms4228 KiB
17Accepted2/29ms4232 KiB
18Accepted3/39ms4228 KiB
19Accepted2/29ms4232 KiB
20Accepted3/39ms4232 KiB
21Accepted2/29ms4520 KiB
22Accepted3/39ms4728 KiB