問題一覧 > 通常問題

No.1948 Puzzle Game Where You Just Add (1)

レベル : / AI推定難易度 : 800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 136
作問者 : H20 / テスター : 蜜蜂 naskya
お気に入りにしたユーザー ProblemId : 7917 / 自分の提出
問題文最終更新日: 2022-05-05 15:26:47
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 344 (順位表) の他の問題:

Problem Statement

DHMO got curious about a puzzle game whose ads keep appearing on a social media app, and decided to play it.
The puzzle game is played by moving a player within a grid with $H$ rows and $W$ columns. The cell in the $i$-th row from the top and the $j$-th column from the left is called $(i,j)$. Cells that do not satisfy ($1 \le i \le H$ and $1 \le j \le W$) do not exist.

The player starts at $(1,1)$ with an attack power of $A_{1,1}$.
Every cell other than $(1,1)$ contains an enemy, and the attack power of the enemy at $(i,j)$ is $A_{i,j}$.
The game is cleared by defeating the boss enemy at $(H,W)$.

When the player is at $(i,j)$, the player can move to whichever of $(i+1,j)$ and $(i,j+1)$ exists.
The player then battles the enemy in the destination cell.
If the player's attack power is higher than the enemy's attack power, the player defeats the enemy, and the player's attack power increases by the enemy's attack power.
If the player's attack power is less than or equal to the enemy's, the player loses, and the game is over unless the player continues.

Upon losing, the player may continue only $1$ time. (This requires watching a 30-second ad twice, but DHMO will put up with it.)
When the player loses at $(i,j)$ and continues, the player avoids the battle with the enemy at $(i,j)$ and can resume the game from $(i,j)$.
In this case, the enemy at $(i,j)$ is not considered defeated, and the player's attack power neither increases nor decreases.
Since a continue does not count as a victory, the player cannot continue at $(H,W)$, and this is treated as game over.

The contents of the puzzle game are given as input.
Determine whether the game can be cleared by controlling the player appropriately.

Input

$H$ $W$
$A_{1,1}$ $A_{1,2}$ $\ldots$ $A_{1,W}$
$A_{2,1}$ $A_{2,2}$ $\ldots$ $A_{2,W}$
$\vdots$
$A_{H,1}$ $A_{H,2}$ $\ldots$ $A_{H,W}$

Constraints

  • $ 2 \le H,W \le 500$
  • $ 1 \le A_{i,j} \le 10^{9}$
  • All inputs are integers.

Output

Print Yes if the game can be cleared, and No otherwise.

Print a newline at the end.

Sample

Sample 1
Input
3 4
10 8 15 50
5 4 40 50
10 1 30 60
Output
Yes

The game can be cleared by moving as shown in the image. The player loses the battle at cell $(2,3)$, but may continue once.

Sample 2
Input
2 5
10 5 50 10 30
10 10 50 50 20
Output
No

The player could gain enough attack power to defeat the boss enemy, but cannot reach the boss enemy.

Sample 3
Input
2 2
10 2
1 12
Output
No

If the player's attack power is equal to the enemy's, the player loses. Also, the player cannot continue in the battle with the boss enemy.

Sample 4
Input
5 5
3 2 2 5 20
2 8 1 3 10
9 4 20 40 10
8 7 32 22 88
20 13 26 51 100 
Output
Yes

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。