結果
問題 | No.971 いたずらっ子 |
ユーザー | leaf_1415 |
提出日時 | 2020-01-18 02:37:01 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 147 ms / 2,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 810 ms |
コンパイル使用メモリ | 52,436 KB |
実行使用メモリ | 38,760 KB |
最終ジャッジ日時 | 2023-08-07 07:59:41 |
合計ジャッジ時間 | 3,111 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 147 ms
38,688 KB |
testcase_01 | AC | 146 ms
38,684 KB |
testcase_02 | AC | 104 ms
32,036 KB |
testcase_03 | AC | 136 ms
38,688 KB |
testcase_04 | AC | 127 ms
38,760 KB |
testcase_05 | AC | 135 ms
38,684 KB |
testcase_06 | AC | 100 ms
36,160 KB |
testcase_07 | AC | 4 ms
10,184 KB |
testcase_08 | AC | 31 ms
23,364 KB |
testcase_09 | AC | 28 ms
23,344 KB |
testcase_10 | AC | 10 ms
37,248 KB |
testcase_11 | AC | 2 ms
5,552 KB |
testcase_12 | AC | 2 ms
5,428 KB |
testcase_13 | AC | 9 ms
37,180 KB |
testcase_14 | AC | 2 ms
5,460 KB |
testcase_15 | AC | 9 ms
37,168 KB |
testcase_16 | AC | 2 ms
5,524 KB |
testcase_17 | AC | 1 ms
5,628 KB |
testcase_18 | AC | 2 ms
5,576 KB |
testcase_19 | AC | 2 ms
5,640 KB |
testcase_20 | AC | 2 ms
5,432 KB |
testcase_21 | AC | 2 ms
5,624 KB |
testcase_22 | AC | 2 ms
5,540 KB |
testcase_23 | AC | 2 ms
5,428 KB |
testcase_24 | AC | 2 ms
5,632 KB |
ソースコード
#include <iostream> #define llint long long #define inf 1e18 using namespace std; llint h, w; char c[2005][2005]; llint dp[2005][2005]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> h >> w; for(int y = 1; y <= h; y++){ for(int x = 1; x <= w; x++){ cin >> c[x][y]; } } for(int y = 1; y <= h; y++){ for(int x = 1; x <= w; x++){ dp[x][y] = inf; } } dp[1][1] = 0; for(int y = 1; y <= h; y++){ for(int x = 1; x <= w; x++){ llint cost = 1; if(c[x][y] == 'k') cost += (x-1)+(y-1); if(x >= 2) dp[x][y] = min(dp[x][y], dp[x-1][y] + cost); if(y >= 2) dp[x][y] = min(dp[x][y], dp[x][y-1] + cost); } } cout << dp[w][h] << endl; return 0; }