44962023-03-29 10:41:24ZsofiaKeresztelyDinamitcpp14Wrong answer 18/509ms5264 KiB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define fi first
#define se second

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<=n; i++){
        for (int j=1; j<=m; j++){
            dp[i][j][0] = min(dp[i][j][0], t[i][j]+min(dp[i][j-1][0], dp[i-1][j][0]));
            for (int l=1; l<=k; l++){
                dp[i][j][l] = dp[i][j][l-1];
                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
base18/50
1Accepted0/03ms1812 KiB
2Wrong answer0/09ms2568 KiB
3Accepted2/23ms2520 KiB
4Accepted2/23ms2736 KiB
5Accepted3/33ms3000 KiB
6Accepted3/33ms3164 KiB
7Accepted2/28ms3628 KiB
8Wrong answer0/39ms3708 KiB
9Wrong answer0/23ms3412 KiB
10Wrong answer0/23ms3620 KiB
11Wrong answer0/33ms3704 KiB
12Wrong answer0/33ms4196 KiB
13Accepted2/24ms4012 KiB
14Wrong answer0/34ms4268 KiB
15Accepted2/29ms4832 KiB
16Wrong answer0/39ms4692 KiB
17Wrong answer0/29ms4988 KiB
18Wrong answer0/39ms5024 KiB
19Accepted2/29ms5224 KiB
20Wrong answer0/39ms5264 KiB
21Wrong answer0/29ms5028 KiB
22Wrong answer0/39ms5028 KiB