Submission #701749

#TimeUsernameProblemLanguageResultExecution timeMemory
701749scottchouMaja (COCI18_maja)C++17
44 / 110
15 ms468 KiB
#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 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...