8772022-01-24 17:35:28Babják PéterDinamitcpp11Accepted 50/508ms3900 KiB
#include <bits/stdc++.h>
#define MN 110
using namespace std;
//17:28
int dp[MN][MN][MN],t[MN][MN],n,m,kk;
signed main()
{
	cin>>n>>m>>kk;
	for(int i=0;i<=n;i++) for(int j=0;j<=m;j++) for(int k=0;k<=kk;k++) dp[i][j][k]=INT_MAX;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>t[i][j];
	for(int k=0;k<=kk;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				int x=t[i][j];
				for(int l=0;l<=k;l++)
				{
					if(i==1 && j==1)dp[i][j][k]=x;
					else dp[i][j][k]=min(dp[i][j][k],min(dp[i-1][j][k-l],dp[i][j-1][k-l])+x);
					x>>=1;
				}
			}
		}
	}
	cout<<dp[n][m][kk]<<'\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms1876 KiB
2Accepted0/07ms3636 KiB
3Accepted2/22ms3704 KiB
4Accepted2/22ms3720 KiB
5Accepted3/32ms3728 KiB
6Accepted3/32ms3748 KiB
7Accepted2/26ms3764 KiB
8Accepted3/37ms3776 KiB
9Accepted2/28ms2100 KiB
10Accepted2/21ms2112 KiB
11Accepted3/31ms2116 KiB
12Accepted3/32ms2116 KiB
13Accepted2/23ms2552 KiB
14Accepted3/32ms2556 KiB
15Accepted2/27ms3820 KiB
16Accepted3/36ms3828 KiB
17Accepted2/27ms3844 KiB
18Accepted3/37ms3852 KiB
19Accepted2/27ms3868 KiB
20Accepted3/37ms3880 KiB
21Accepted2/27ms3888 KiB
22Accepted3/37ms3900 KiB