# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92158 | 2019-01-01T19:08:09 Z | Kastanda | Maja (COCI18_maja) | C++11 | 100 ms | 632 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Incorrect | 2 ms | 504 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 540 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Incorrect | 2 ms | 504 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 100 ms | 592 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 632 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |