49372023-04-07 16:51:05TomaSajtDinamitcpp17Wrong answer 18/5012ms4844 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0), ios::sync_with_stdio(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int>> board(n + 1, vector<int>(m + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> board[i][j];
    }
  }

  // what is the min cost of getting to [i;j] with d dynamites
  vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(m + 1, vector<int>(k + 1, INT_MAX / 2)));

  dp[1][1][0] = board[1][1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int d = 0; d <= k; d++) {
        for (int dd = 0; dd <= d; dd++) {
          dp[i][j][d] = min(dp[i][j][d], (board[i][j] / (1 << dd)) + min(dp[i][j - 1][d - dd], dp[i - 1][j][d - dd]));
        }
      }
    }
  }
  cout << dp[n][m][k];
}
SubtaskSumTestVerdictTimeMemory
base18/50
1Accepted0/03ms1828 KiB
2Wrong answer0/012ms2708 KiB
3Accepted2/23ms2472 KiB
4Accepted2/23ms2856 KiB
5Accepted3/33ms2928 KiB
6Accepted3/33ms3136 KiB
7Accepted2/212ms3776 KiB
8Wrong answer0/312ms3988 KiB
9Wrong answer0/23ms3668 KiB
10Wrong answer0/23ms3876 KiB
11Wrong answer0/33ms4088 KiB
12Wrong answer0/33ms4048 KiB
13Accepted2/24ms4368 KiB
14Wrong answer0/34ms4252 KiB
15Accepted2/212ms4720 KiB
16Wrong answer0/312ms4716 KiB
17Wrong answer0/212ms4716 KiB
18Wrong answer0/312ms4720 KiB
19Accepted2/212ms4716 KiB
20Wrong answer0/312ms4720 KiB
21Wrong answer0/212ms4720 KiB
22Wrong answer0/312ms4844 KiB