Submission #74084
ソースコード
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 30 31 32 33 34 35 36 37 38 39 | #include<bits/stdc++.h> #define rep(i,a,n) for(long long i=a;i<n;i++) #define repp(i,a,n) for(long long i=a;i>=n;i--) #define so(z) sort(z.begin(),z.end()) #define sor(z) sort(z.begin(),z.end(),greater<int>()) #define set(n) setprecision(n) #define cout(a) cout<<a<<"\n" #define yess cout<<"YES"<<nn #define noo cout<<"NO"<<nn #define yes cout<<"Yes"<<"\n" #define no cout<<"No"<<"\n" #define fi first #define se second #define nn "\n" #define ll long long #define fu 1000000007 #define IM INT_MAX #define LM LONG_MAX #define re(a) return(a) #define prev(a) prev_permutation(a.begin(),a.end()) #define next(a) next_permutation(a.begin(),a.end()) #define get(s) getline(cin,s) using namespace std; int main(){ int h,w; cin>>h>>w; int a[h+1][w+1],dp[h+1][w+1]; rep(i,1,h+1){ rep(j,1,w+1){ cin>>a[i][j]; if (i==1&&j==1) dp[i][j]=a[i][j]; else if (i==1) dp[i][j]=dp[i][j-1]+a[i][j]; else if (j==1) dp[i][j]=dp[i-1][j]+a[i][j]; else dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j]; } } cout<<dp[h][w]<<nn; return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0910 - 百円以下の拾得物 |
ユーザー名 | r2201 |
投稿日時 | 2022-12-15 16:59:04 |
言語 | C++17 |
状態 | Accepted |
得点 | 3 |
ソースコード長 | 1148 Byte |
最大実行時間 | 221 ms |
最大メモリ使用量 | 25752 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 3 / 3 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 54 ms | 604 KB |
1
|
in02.txt | AC | 23 ms | 444 KB |
1
|
in03.txt | AC | 21 ms | 412 KB |
1
|
in04.txt | AC | 29 ms | 516 KB |
1
|
in05.txt | AC | 22 ms | 492 KB |
1
|
in06.txt | AC | 177 ms | 12116 KB |
1
|
in07.txt | AC | 186 ms | 15912 KB |
1
|
in08.txt | AC | 201 ms | 20728 KB |
1
|
in09.txt | AC | 221 ms | 25548 KB |
1
|
in10.txt | AC | 69 ms | 17820 KB |
1
|
in11.txt | AC | 125 ms | 25752 KB |
1
|
sample_in_1.txt | AC | 20 ms | 20684 KB |
1
|
sample_in_2.txt | AC | 27 ms | 20784 KB |
1
|