답안 #363131

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363131 2021-02-05T06:35:19 Z lukameladze Maxcomp (info1cup18_maxcomp) C++14
100 / 100
409 ms 19308 KB
# include <bits/stdc++.h>
using namespace std;
long long n,m,a[1005][1005],dp[1005][1005],ans;
int main() {
     cin>>n>>m;
     for (int i=1; i<=n; i++) {
          for (int j=1; j<=m; j++) {
               cin>>a[i][j];
          }
     }
     for (int i=1; i<=n; i++) {
          for (int j=1; j<=m; j++) {
               dp[i][j]=a[i][j];
               if(i>1) dp[i][j]=max(dp[i][j], dp[i-1][j]-1);
               if(j>1) dp[i][j]=max(dp[i][j],dp[i][j-1]-1);
            }
     }
     for (int i=n; i>=1; i--) {
          for (int j=m; j>=1; j--) {
               dp[i][j]=max(a[i][j],dp[i][j]);
               if(j<m) dp[i][j]=max(dp[i][j], dp[i][j+1]-1);
               if(i<n) dp[i][j]=max(dp[i][j],dp[i+1][j]-1);
          }
     }
     for (int i=1; i<=n; i++) {
          for (int j=1; j<=m; j++) {
               ans=max(ans,dp[i][j]-a[i][j]);
          }
     }
     cout<<ans-1<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 2 ms 748 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 2 ms 748 KB Output is correct
12 Correct 2 ms 748 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Correct 2 ms 752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 748 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Correct 2 ms 748 KB Output is correct
15 Correct 2 ms 748 KB Output is correct
16 Correct 2 ms 748 KB Output is correct
17 Correct 2 ms 752 KB Output is correct
18 Correct 397 ms 19308 KB Output is correct
19 Correct 409 ms 18708 KB Output is correct
20 Correct 381 ms 18732 KB Output is correct
21 Correct 387 ms 18924 KB Output is correct
22 Correct 392 ms 18668 KB Output is correct
23 Correct 385 ms 18500 KB Output is correct
24 Correct 408 ms 17952 KB Output is correct