# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
701749 |
2023-02-22T03:34:02 Z |
scottchou |
Maja (COCI18_maja) |
C++17 |
|
15 ms |
468 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int const N = 105;
LL dp[2][N][N];
LL c[N][N];
int dis[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, m, k, x, y;
cin >> n >> m >> x >> y >> k;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> c[i][j];
dp[0][i][j] = -1e18;
}
}
if(k <= 10000){
bool now = 0;
dp[0][x][y] = 0;
while(k--){
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
dp[!now][i][j] = -1e18;
for(int s = 0; s < 4; s++){
int tox = i + dis[s][0], toy = j +dis[s][1];
if(tox > 0 && tox <= n && toy > 0 && toy <= m){
dp[!now][i][j] = max(dp[!now][i][j], dp[now][tox][toy]);
}
}
dp[!now][i][j] += c[i][j];
}
}
now = !now;
}
cout << dp[now][x][y];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
12 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
15 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
340 KB |
Output is correct |
2 |
Correct |
6 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |