/ WOJ /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 2ms 476.0 KiB
#2 Wrong Answer 1ms 344.0 KiB
#3 Wrong Answer 1ms 480.0 KiB
#4 Wrong Answer 1ms 484.0 KiB
#5 Wrong Answer 1ms 476.0 KiB
#6 Wrong Answer 1ms 476.0 KiB
#7 Wrong Answer 1ms 476.0 KiB
#8 Wrong Answer 1ms 468.0 KiB
#9 Wrong Answer 2ms 476.0 KiB
#10 Wrong Answer 1ms 480.0 KiB

代码

#include <bits/extc++.h>
#define endl '\n'
typedef long long ll;
#define int ll
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

void Main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> t(n + 1, vector<int>(m + 1)),
      d(n + 1, vector<int>(m + 1));
  vector<vector<vector<int>>> dp(
      n + 1, vector<vector<int>>(m + 1, vector<int>(2, 0x3f3f3f3f3f3f3f3f)));
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> t[i][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> d[i][j];
    }
  }
  dp[1][1][1] = t[1][1] + d[1][1];
  dp[1][1][0] = t[1][1];
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (j > 1) {
        dp[i][j][0] =
            min(dp[i][j - 1][0] + t[i][j], dp[i][j - 1][1] + t[i][j] + d[i][j]);
      }
      if (i > 1) {
        dp[i][j][1] =
            min(dp[i - 1][j][1] + t[i][j], dp[i - 1][j][0] + t[i][j] + d[i][j]);
      }
    }
  }
  cout << dp[n][m][1] << endl;
}

signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    Main();
  }
  return 0;
}
// DP

信息

递交者
类型
递交
题目
P1000 云剪贴板
题目数据
下载
语言
C++
递交时间
2025-03-08 10:46:09
评测时间
2025-03-08 10:46:10
评测机
分数
0
总耗时
19ms
峰值内存
484.0 KiB