49382023-04-07 16:53:27TomaSajtDinamitcpp17Wrong answer 10/506ms5152 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 d = 1; d <= k; d++)
    dp[1][1][d] = dp[1][1][d - 1] / 2;

  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] >> d) + min(dp[i][j - 1][d - dd], dp[i - 1][j][d - dd]));
        }
      }
    }
  }
  cout << dp[n][m][k];
}
SubtaskSumTestVerdictTimeMemory
base10/50
1Wrong answer0/03ms1832 KiB
2Wrong answer0/06ms2708 KiB
3Accepted2/23ms2464 KiB
4Accepted2/23ms2720 KiB
5Accepted3/33ms2928 KiB
6Accepted3/33ms3312 KiB
7Wrong answer0/24ms3556 KiB
8Wrong answer0/36ms3920 KiB
9Wrong answer0/23ms3392 KiB
10Wrong answer0/23ms3268 KiB
11Wrong answer0/33ms3396 KiB
12Wrong answer0/33ms3544 KiB
13Wrong answer0/23ms3576 KiB
14Wrong answer0/33ms3580 KiB
15Wrong answer0/26ms4172 KiB
16Wrong answer0/36ms4440 KiB
17Wrong answer0/26ms4908 KiB
18Wrong answer0/36ms4752 KiB
19Wrong answer0/26ms4652 KiB
20Wrong answer0/36ms4800 KiB
21Wrong answer0/26ms4760 KiB
22Wrong answer0/36ms5152 KiB