結果

問題 No.2328 Build Walls
ユーザー shop_oneshop_one
提出日時 2023-05-28 14:44:17
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 985 bytes
コンパイル時間 1,293 ms
コンパイル使用メモリ 113,436 KB
実行使用メモリ 13,304 KB
最終ジャッジ日時 2023-08-27 10:29:52
合計ジャッジ時間 3,794 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 33 ms
8,320 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 6 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 28 ms
8,188 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 54 ms
13,012 KB
testcase_29 WA -
testcase_30 AC 63 ms
13,036 KB
testcase_31 AC 62 ms
13,020 KB
testcase_32 WA -
testcase_33 AC 64 ms
13,124 KB
testcase_34 AC 64 ms
13,108 KB
testcase_35 AC 68 ms
13,060 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll INF = 1e9;
signed main(){
  init_io();
  ll h,w;
  cin >> h >> w;
  vector<vector<ll>> a(h, vector<ll>(w, -1));
  vector<vector<ll>> dp(h, vector<ll>(w, INF));
  for(int i=1;i<h-1;i++){
    for(int j=0;j<w;j++) {
      cin >> a[i][j];
      if (j==0 && a[i][j] != -1) dp[i][j] = a[i][j];
    }
  }
  for (int j=1;j<w;j++) {
    for (int i=1;i<h-1;i++) {
      if (a[i][j] == -1) continue;
      dp[i][j] = a[i][j] + min(dp[i-1][j-1], min(dp[i][j-1], dp[i+1][j-1]));
    }
  }
  ll ans = INF;
  for (int i=0;i<h;i++) {
    ans = min(ans, dp[i][w-1]);
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
}
0