제출 #780798

#제출 시각아이디문제언어결과실행 시간메모리
780798AndreyMaxcomp (info1cup18_maxcomp)C++14
100 / 100
99 ms20640 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,a,b,ans = 0;
    cin >> n >> m;
    int haha[n][m];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> haha[i][j];
        }
    }
    pair<int,int> dp[n][m];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            dp[i][j] = {haha[i][j]+i+j,-haha[i][j]+i+j};
            if(i > 0) {
                dp[i][j] = {max(dp[i][j].first,dp[i-1][j].first),max(dp[i][j].second,dp[i-1][j].second)};
            }
            if(j > 0) {
                dp[i][j] = {max(dp[i][j].first,dp[i][j-1].first),max(dp[i][j].second,dp[i][j-1].second)};
            }
            ans = max(ans,dp[i][j].first-haha[i][j]-i-j);
            ans = max(ans,dp[i][j].second+haha[i][j]-i-j);
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m/2; j++) {
            swap(haha[i][j],haha[i][m-j-1]);
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            dp[i][j] = {haha[i][j]+i+j,-haha[i][j]+i+j};
            if(i > 0) {
                dp[i][j] = {max(dp[i][j].first,dp[i-1][j].first),max(dp[i][j].second,dp[i-1][j].second)};
            }
            if(j > 0) {
                dp[i][j] = {max(dp[i][j].first,dp[i][j-1].first),max(dp[i][j].second,dp[i][j-1].second)};
            }
            ans = max(ans,dp[i][j].first-haha[i][j]-i-j);
            ans = max(ans,dp[i][j].second+haha[i][j]-i-j);
        }
    }
    cout << ans-1;
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:9:13: warning: unused variable 'a' [-Wunused-variable]
    9 |     int n,m,a,b,ans = 0;
      |             ^
maxcomp.cpp:9:15: warning: unused variable 'b' [-Wunused-variable]
    9 |     int n,m,a,b,ans = 0;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...