2382021-03-05 14:19:11balintttDinamitcpp14Accepted 50/5014ms3172 KiB
#include<bits/stdc++.h>

using namespace std;

long long k[41][41][41];

int n, m, l;

int t[41][41];

int main(){
    cin >> n >> m >> l;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            for(int o=0;o<=l;o++){
                k[i][j][o]=INT_MAX;
                t[i][j]=INT_MAX;
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> t[i][j];
        }
    }
    k[1][0][0] = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            for(int o=0;o<=l;o++){
                for(int p=0;p+o<=l;p++){
                    k[i][j][o+p] = min(k[i][j][o+p], min(k[i-1][j][o]+t[i][j]/(1<<p),k[i][j-1][o]+t[i][j]/(1<<p)));
                }
            }
        }
    }
    cout << k[n][m][l] << '\n';
return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1836 KiB
2Accepted0/014ms3004 KiB
3Accepted2/22ms2968 KiB
4Accepted2/22ms2988 KiB
5Accepted3/32ms3004 KiB
6Accepted3/32ms3012 KiB
7Accepted2/210ms3020 KiB
8Accepted3/310ms3036 KiB
9Accepted2/22ms2084 KiB
10Accepted2/22ms2088 KiB
11Accepted3/32ms2092 KiB
12Accepted3/33ms2096 KiB
13Accepted2/24ms2376 KiB
14Accepted3/34ms2376 KiB
15Accepted2/212ms3080 KiB
16Accepted3/310ms3092 KiB
17Accepted2/212ms3100 KiB
18Accepted3/310ms3112 KiB
19Accepted2/210ms3172 KiB
20Accepted3/310ms3136 KiB
21Accepted2/210ms3152 KiB
22Accepted3/310ms3164 KiB