44972023-03-29 10:48:09ZsofiaKeresztelyDinamitcpp14Wrong answer 18/5025ms5052 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<=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]));
                }
            }
        }
    }
    /*for (int l=0; l<=k; l++){
        for (int i=1; i<=n; i++){
            for (int j=1; j<=m; j++){
                cout << dp[i][j][l] << " ";
            }
            cout << "\n";
        }
        cout << "\n";
    }*/
    cout << dp[n][m][k];
}
SubtaskSumTestVerdictTimeMemory
base18/50
1Accepted0/03ms1812 KiB
2Wrong answer0/025ms3224 KiB
3Accepted2/23ms2196 KiB
4Accepted2/23ms2452 KiB
5Accepted3/33ms2408 KiB
6Accepted3/33ms2668 KiB
7Accepted2/224ms3608 KiB
8Wrong answer0/325ms3872 KiB
9Wrong answer0/24ms3084 KiB
10Wrong answer0/24ms2988 KiB
11Wrong answer0/34ms2988 KiB
12Wrong answer0/34ms3376 KiB
13Accepted2/28ms3548 KiB
14Wrong answer0/38ms3804 KiB
15Accepted2/225ms4700 KiB
16Wrong answer0/325ms4656 KiB
17Wrong answer0/225ms4664 KiB
18Wrong answer0/325ms4676 KiB
19Accepted2/225ms5052 KiB
20Wrong answer0/325ms4876 KiB
21Wrong answer0/225ms5004 KiB
22Wrong answer0/325ms5020 KiB