3532021-10-26 18:04:23goczbaliDinamitcpp14Wrong answer 35/5028ms3012 KiB
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

using ll = long long;

int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    vector<vector<ll>> cost(n + 1, vector<ll>(m + 1));
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            cin >> cost[i][j];
        }
    }

    vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(m + 1, vector<ll>(k + 1, numeric_limits<ll>::max() / 2 - 1)));

    for (int i = 0; i <= k; i++) {
        dp[0][1][i] = 0;
        dp[1][0][i] = 0;
    }

    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            for (ll x = 0; x <= k; x++) {
                dp[i][j][x] = min(dp[i][j][x], min(dp[i - 1][j][x] + cost[i][j], dp[i][j - 1][x] + cost[i][j]));

                for (ll y = x + 1; y <= k; y++) {
                    ll c = cost[i][j] / (2 * (y - x));

                    dp[i][j][y] = min(dp[i][j][y], min(dp[i - 1][j][x] + c, dp[i][j - 1][x] + c));
                }
            }
        }
    }

    cout << dp[n][m][k] << endl;
}
SubtaskSumTestVerdictTimeMemory
base35/50
1Accepted0/02ms1752 KiB
2Accepted0/027ms2764 KiB
3Accepted2/22ms2092 KiB
4Accepted2/23ms1980 KiB
5Accepted3/32ms1992 KiB
6Accepted3/32ms2140 KiB
7Accepted2/228ms2760 KiB
8Accepted3/328ms2780 KiB
9Wrong answer0/24ms1984 KiB
10Wrong answer0/23ms1992 KiB
11Wrong answer0/33ms1992 KiB
12Wrong answer0/32ms1996 KiB
13Wrong answer0/26ms2252 KiB
14Wrong answer0/36ms2252 KiB
15Accepted2/221ms2812 KiB
16Accepted3/320ms2952 KiB
17Accepted2/228ms2844 KiB
18Accepted3/321ms2972 KiB
19Accepted2/221ms2864 KiB
20Accepted3/324ms2876 KiB
21Accepted2/226ms3012 KiB
22Accepted3/328ms2900 KiB