Submission #68155
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <bits/stdc++.h> using namespace std; int h,w; vector<vector< int >> m(1000,vector< int >(1000,0)); vector<vector< int >> mem(1000,vector< int >(1000,0)); vector<vector< bool >> f(1000,vector< bool >(1000, false )); int func( int y, int x); signed main(){ cin.tie(nullptr); ios_base::sync_with_stdio( false ); cin>>h>>w; for ( int i=0;i<h;i++){ for ( int j=0;j<w;j++){ cin>>m[i][j]; } } cout<<func(h-1,w-1)<<endl; return 0; } int func( int y, int x){ if (y<0||y>=h||x<0||x>=w){ return 0; } if (f[y][x]== false ){ mem[y][x]=m[y][x]+max(func(y-1,x),func(y,x-1)); f[y][x]= true ; } return (mem[y][x]); } |
ステータス
項目 | データ |
---|---|
問題 | 0910 - 百円以下の拾得物 |
ユーザー名 | ei2009 |
投稿日時 | 2021-08-24 10:49:39 |
言語 | C++17 |
状態 | Accepted |
得点 | 3 |
ソースコード長 | 707 Byte |
最大実行時間 | 141 ms |
最大メモリ使用量 | 29048 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 3 / 3 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 38 ms | 8668 KB |
1
|
in02.txt | AC | 32 ms | 8740 KB |
1
|
in03.txt | AC | 24 ms | 8684 KB |
1
|
in04.txt | AC | 24 ms | 8508 KB |
1
|
in05.txt | AC | 38 ms | 8584 KB |
1
|
in06.txt | AC | 105 ms | 12628 KB |
1
|
in07.txt | AC | 135 ms | 16392 KB |
1
|
in08.txt | AC | 141 ms | 21180 KB |
1
|
in09.txt | AC | 120 ms | 25836 KB |
1
|
in10.txt | AC | 49 ms | 25888 KB |
1
|
in11.txt | AC | 83 ms | 29020 KB |
1
|
sample_in_1.txt | AC | 30 ms | 28844 KB |
1
|
sample_in_2.txt | AC | 28 ms | 29048 KB |
1
|