# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403693 | joelau | 조개 줍기 (KOI17_shell) | C++14 | 13 ms | 632 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int N, A[100][100], dp[100][100];
int main() {
scanf("%d", &N);
for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) scanf("%d", &A[i][j]);
long long ans = 0;
for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
dp[i][j] = 0;
if (i != 0) dp[i][j] = max(dp[i][j],dp[i-1][j]);
if (j != 0) dp[i][j] = max(dp[i][j],dp[i][j-1]);
dp[i][j] += A[i][j];
ans += dp[i][j];
}
printf("%lld\n", ans);
for (int a = 0; a < N; ++a) {
char c; int x,y; scanf(" %c %d %d", &c, &x, &y), x--, y--;
if (c == 'U') A[x][y]++;
else A[x][y]--;
long long ans = 0;
for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
dp[i][j] = 0;
if (i != 0) dp[i][j] = max(dp[i][j],dp[i-1][j]);
if (j != 0) dp[i][j] = max(dp[i][j],dp[i][j-1]);
dp[i][j] += A[i][j];
ans += dp[i][j];
}
printf("%lld\n", ans);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |