結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー tailstails
提出日時 2022-05-20 22:35:06
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 1,477 ms
コンパイル使用メモリ 30,596 KB
実行使用メモリ 7,712 KB
最終ジャッジ日時 2023-10-20 13:19:59
合計ジャッジ時間 3,148 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 29 ms
6,528 KB
testcase_08 AC 36 ms
4,580 KB
testcase_09 AC 39 ms
6,528 KB
testcase_10 AC 39 ms
7,712 KB
testcase_11 AC 39 ms
7,708 KB
testcase_12 AC 33 ms
7,712 KB
testcase_13 AC 33 ms
7,336 KB
testcase_14 AC 33 ms
7,712 KB
testcase_15 AC 32 ms
6,528 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 5 ms
6,524 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 37 ms
7,712 KB
testcase_21 AC 36 ms
7,700 KB
testcase_22 AC 31 ms
7,712 KB
testcase_23 AC 29 ms
6,528 KB
testcase_24 AC 30 ms
7,712 KB
testcase_25 AC 38 ms
7,624 KB
testcase_26 AC 39 ms
7,712 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:5:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |         scanf("%ld%ld",&h,&w);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | long d[2][500][500];
main.c:5:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |         scanf("%ld%ld",&h,&w);
      |         ^~~~~
main.c:5:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:34:9: warning: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
   34 |         puts(d[0][h-1][w-1]|d[1][h-1][w-1]>a[h-1][w-1]?"Yes":"No");
      |         ^~~~
main.c:34:9: note: include '<stdio.h>' or provide a declaration of 'puts'

ソースコード

diff #

long d[2][500][500];
long a[500][500];
int main(){
	long h,w;
	scanf("%ld%ld",&h,&w);
	for(long y=0;y<h;++y){
		for(long x=0;x<w;++x){
			scanf("%ld",&a[y][x]);
		}
	}
	d[0][0][0]=a[0][0];
	for(long f=0;f<2;++f){
		for(long y=0;y<h;++y){
			for(long x=0;x<w;++x){
				if(y<h-1){
					if(d[f][y][x]>a[y+1][x]&&d[f][y+1][x]<d[f][y][x]+a[y+1][x]){
						d[f][y+1][x]=d[f][y][x]+a[y+1][x];
					}
					if(f==0&&d[1][y+1][x]<d[0][y][x]){
						d[1][y+1][x]=d[0][y][x];
					}
				}
				if(x<w-1){
					if(d[f][y][x]>a[y][x+1]&&d[f][y][x+1]<d[f][y][x]+a[y][x+1]){
						d[f][y][x+1]=d[f][y][x]+a[y][x+1];
					}
					if(f==0&&d[1][y][x+1]<d[0][y][x]){
						d[1][y][x+1]=d[0][y][x];
					}
				}
			}
		}
	}
	puts(d[0][h-1][w-1]|d[1][h-1][w-1]>a[h-1][w-1]?"Yes":"No");
}
0