1 条题解
-
0
#include <bits/stdc++.h> using namespace std; // 打了最多的 1000 只怪,每只怪都打了 100 次,每次受到 100 点 const int INF = 1000 * 100 * 100; int n, m, t, k, h, atk; int dp[505][505][15]; int a[505][505]; // 之前最小伤害为 base,用 atk 的攻击力挑战 i,j,并更新 i,j,x void fresh(int i, int j, int x, int base, int atk) { if (i > n || j > m) return; int now = (h - 1) / atk * a[i][j]; // 当前受到的伤害 dp[i][j][x] = min(dp[i][j][x], base + now); } // 正在技能期间,(i,j,x),是技能的 第 step 步,之前总伤害 base,当前攻击力 atk void dfs(int i, int j, int x, int step, int base, int atk) { if (i > n || j > m) return; // 起点不能算 // 其他位置叠加当前位置的攻击加成,并扣血量 if (step != 0) { atk += a[i][j]; base += (h - 1) / atk * a[i][j]; } if (step == k) { dp[i][j][x] = min(dp[i][j][x], base); return; } dfs(i + 1, j, x, step + 1, base, atk); dfs(i, j + 1, x, step + 1, base, atk); } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m >> t >> k >> h >> atk; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j]; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) for (int x = 0; x <= t; x++) dp[i][j][x] = INF; dp[1][1][0] = 0; for (int x = 0; x <= t; x++) for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { if (dp[i][j][x] == INF) continue; // 不使用技能走到后面位置 fresh(i + 1, j, x, dp[i][j][x], atk); fresh(i, j + 1, x, dp[i][j][x], atk); // 使用技能走到后面位置 dfs(i, j, x + 1, 0, dp[i][j][x], atk); } int ans = dp[n][m][0]; for (int x = 1; x <= t; x++) ans = min(ans, dp[n][m][x]); cout << ans; return 0; }
- 1
信息
- ID
- 13246
- 时间
- 2000ms
- 内存
- 512MiB
- 难度
- 9
- 标签
- (无)
- 递交数
- 15
- 已通过
- 3
- 上传者