Submission #67005

#TimeUsernameProblemLanguageResultExecution timeMemory
67005ekremMaxcomp (info1cup18_maxcomp)C++98
60 / 100
515 ms71932 KiB
#include <bits/stdc++.h> #define st first #define nd second #define mp make_pair #define pb push_back #define inf 2000000007 #define N 1005 using namespace std; typedef long long ll; ll n, m, ans = -inf, a[N][N], dp[N][N][4][2]; ll o[] = {-1, 0, 1, 0}; ll p[] = {0, 1, 0, -1}; ll f(ll i, ll j, ll yon, ll dur){ ll &r = dp[i][j][yon][dur]; if(r != -1) return r; if(i < 1 or j < 1 or i > n or j > m) return -inf; if(dur == 0){ if(a[i][j] > f(i + o[yon], j + p[yon], yon, dur) - 1) r = a[i][j]; else r = f(i + o[yon], j + p[yon], yon, dur) - 1; } if(dur == 1){ if(-a[i][j] > f(i + o[yon], j + p[yon], yon, dur) - 1) r = -a[i][j]; else r = f(i + o[yon], j + p[yon], yon, dur) - 1; } return r; } int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); memset(dp, -1, sizeof dp); scanf("%lld %lld",&n ,&m); for(ll i = 1; i <= n; i++) for(ll j = 1; j <= m; j++) scanf("%lld",&a[i][j]); for(ll i = 1; i <= n; i++) for(ll j = 1; j <= m; j++) for(ll l = 0; l <= 3; l++) for(ll k = 0; k <= 3; k++) if(l != k){ ans = max(ans, f(i, j, l, 0) + f(i, j, k, 1) - 1 ); } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n ,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
maxcomp.cpp:42:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld",&a[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...