結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー koryoukoryou
提出日時 2022-05-21 00:21:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,085 bytes
コンパイル時間 912 ms
コンパイル使用メモリ 105,348 KB
実行使用メモリ 89,932 KB
最終ジャッジ日時 2023-10-20 15:12:34
合計ジャッジ時間 3,965 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,604 KB
testcase_01 AC 2 ms
5,600 KB
testcase_02 AC 3 ms
5,600 KB
testcase_03 AC 2 ms
5,616 KB
testcase_04 AC 2 ms
5,600 KB
testcase_05 AC 2 ms
5,600 KB
testcase_06 WA -
testcase_07 AC 76 ms
87,212 KB
testcase_08 AC 123 ms
86,224 KB
testcase_09 AC 138 ms
86,224 KB
testcase_10 AC 125 ms
86,224 KB
testcase_11 AC 120 ms
86,132 KB
testcase_12 AC 98 ms
89,932 KB
testcase_13 AC 105 ms
89,932 KB
testcase_14 AC 95 ms
89,932 KB
testcase_15 AC 95 ms
89,932 KB
testcase_16 AC 3 ms
5,756 KB
testcase_17 AC 18 ms
89,584 KB
testcase_18 WA -
testcase_19 AC 3 ms
7,672 KB
testcase_20 AC 97 ms
89,932 KB
testcase_21 AC 93 ms
89,928 KB
testcase_22 AC 82 ms
89,932 KB
testcase_23 AC 82 ms
89,932 KB
testcase_24 AC 81 ms
89,932 KB
testcase_25 AC 114 ms
87,876 KB
testcase_26 AC 118 ms
89,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <list>
#include <cassert>
#include <numeric>
#include <cstdint>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <random>
#include <bitset>
// #include <atcoder/all>
 
using ll = long long;
using ld = long double;
using namespace std;
// using namespace atcoder;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
using Priority = priority_queue<ll, vector<ll>, greater<ll>>;// 昇順
using Priority_pair = priority_queue<P, vector<P>, greater<P>>;
// using mint_17 = modint1000000007;
// using mint = modint998244353;

#define mod 1000000007
#define MAX_WIDTH 60
#define MAX_HEIGHT 60
#define INF 1e18
#define MOD 998244353
#define PI 3.141592653589793
#define rep(i, a, b) for(ll i=(a);i<(b);i++)
#define rrep(i, a, b) for(ll i=(a);i>=(b);i--)
#define fore(i, a) for(auto &i: a)
#define all(v) (v).begin(), (v).end()
#define YES(a) cout << ((a) ? "YES" : "NO") << endl
#define Yes(a) cout << ((a) ? "Yes" : "No") << endl
#define pb(a) push_back(a)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vp vector<pair<ll, ll>>
#define mll map<ll, ll>
#define msl map<string, ll>
#define COUT(n) cout << (n) << endl
#define isInGrid(n, h, w) (0 <= (n) && (n) < (h) && 0 <= (n) && (n) < (w))
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// int vx[] = {1,0,-1,0}, vy[] = {0,1,0,-1};

ll H, W, A[1010][1010];
ll dp[1010][1010][20];
int main() {
    cin >> H >> W;
    rep(i, 0, H) {
        rep(j, 0, W) {
            cin >> A[i][j];
            dp[i][j][0] = dp[i][j][1] = -INF;
        }
    }

    dp[0][0][0] = dp[0][0][1] = A[0][0];
    rep(i, 0, H) {
        rep(j, 0, W) {
            rep(k, 0, 2) {
                // 右
                if(j+1 < W) {
                    if(dp[i][j][k] <= A[i][j+1]) {
                        if(k == 0 && i != H-1 && j+1 != W-1) {
                            chmax(dp[i][j+1][k+1], dp[i][j][k]);
                        }
                    } else {
                        chmax(dp[i][j+1][k], dp[i][j][k] + A[i][j+1]);
                    }
                }

                if(i+1 < H) {
                    if(dp[i][j][k] <= A[i+1][j]) {
                        if(k == 0 && i+1 != H-1 && j != W-1) {
                            chmax(dp[i+1][j][k+1], dp[i][j][k]);
                        }
                    } else {
                        chmax(dp[i+1][j][k], dp[i][j][k] + A[i+1][j]);
                    }
                }
            }
        }
    }

    // cout << dp[H-1][W-1][0] << " " << dp[H-1][W-1][1] << endl;
    // rep(i, 0, H) {
    //     rep(j, 0, W) {
    //         cout << dp[i][j][1] << " ";
    //     }
    //     cout << endl;
    // }

    Yes(dp[H-1][W-1][0] > A[H-1][W-1] || dp[H-1][W-1][1] > A[H-1][W-1]);

    return 0;
}
0