Submission #92158

#TimeUsernameProblemLanguageResultExecution timeMemory
92158KastandaMaja (COCI18_maja)C++11
0 / 110
100 ms632 KiB
#include<bits/stdc++.h> using namespace std; const int N = 105; int n, m, k, a, b, A[N][N]; long long MX, dp[2][N][N]; int main() { scanf("%d%d%d%d%d", &n, &m, &a, &b, &k); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &A[i][j]); memset(dp, -63, sizeof(dp)); dp[0][a][b] = 0; for (int len = 1, w = 1; len <= n * m && len * 2 <= k; len ++, w = !w) { for (int i = 1; i <= n; i++) for (int j = (a + b + i + (!w)) % 2 + 1; j <= n; j += 2) { dp[w][i][j] = max({dp[!w][i-1][j] + A[i-1][j], dp[!w][i+1][j] + A[i+1][j], dp[!w][i][j-1] + A[i][j-1], dp[!w][i][j+1] + A[i][j+1]}); int sum = A[i][j] + max({A[i-1][j], A[i+1][j], A[i][j-1], A[i][j+1]}); MX = max(MX, dp[w][i][j] * 2LL + ((k >> 1) - len) * 1LL * sum + A[i][j]); } } return !printf("%lld\n", MX); }

Compilation message (stderr)

maja.cpp: In function 'int main()':
maja.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d%d", &n, &m, &a, &b, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
maja.cpp:11:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...