結果

問題 No.2095 High Rise
ユーザー pengin_2000pengin_2000
提出日時 2022-10-07 21:57:46
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 697 ms
コンパイル使用メモリ 28,980 KB
実行使用メモリ 17,580 KB
最終ジャッジ日時 2023-09-03 01:46:11
合計ジャッジ時間 3,035 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
6,148 KB
testcase_13 AC 2 ms
6,176 KB
testcase_14 AC 3 ms
6,252 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 19 ms
11,808 KB
testcase_18 AC 14 ms
11,532 KB
testcase_19 AC 5 ms
6,680 KB
testcase_20 AC 19 ms
7,476 KB
testcase_21 AC 35 ms
10,096 KB
testcase_22 AC 139 ms
17,580 KB
testcase_23 AC 140 ms
17,548 KB
testcase_24 AC 139 ms
17,580 KB
testcase_25 AC 139 ms
17,472 KB
testcase_26 AC 138 ms
17,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
long long int a[1003][1003];
long long int dp[1003][1003];
int main()
{
	long long int n, m;
	scanf("%lld %lld", &n, &m);
	long long int i, j;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%lld", &a[i][j]);
	for (j = 0; j < m; j++)
		dp[0][j] = a[0][j];
	long long int min = 0;
	for (i = 1; i < n; i++)
	{
		for (j = 0; j < m; j++)
			dp[i][j] = dp[i - 1][j] + a[i][j];
		min = 1e18;
		for (j = 0; j < m; j++)
			if (min > dp[i][j])
				min = dp[i][j];
		for (j = 0; j < m; j++)
			if (dp[i][j] > min + a[i][j])
				dp[i][j] = min + a[i][j];
	}
	printf("%lld\n", min);
	return 0;
}
0