Submission #345328

#TimeUsernameProblemLanguageResultExecution timeMemory
345328bachaquerUFO (IZhO14_ufo)C++14
30 / 100
2083 ms8948 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n, m, r, k, p; cin >> n >> m >> r >> k >> p; ll l[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> l[i][j]; } } char c; int x, h; for (int t = 0; t < k; t++) { cin >> c >> x >> h; ll ups = 0; if (c == 'W') { for (int j = 0; j < m && ups < r; j++) { if (l[x - 1][j] >= h) { l[x - 1][j]--; ups++; } } } else if (c == 'N') { for (int i = 0; i < n && ups < r; i++) { if (l[i][x - 1] >= h) { l[i][x - 1]--; ups++; } } } else if (c == 'E') { for (int j = m - 1; j >= 0 && ups < r; j--) { if (l[x - 1][j] >= h) { l[x - 1][j]--; ups++; } } } else if (c == 'S') { for (int i = n - 1; i >= 0 && ups < r; i--) { if (l[i][x - 1] >= h) { l[i][x - 1]--; ups++; } } } } ll mx = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { ll sum = 0; if (p > j + 1 || p > i + 1) continue; bool br = false; for (int up = i; up >= i - p + 1; up--) { for (int left = j; left >= j - p + 1; left--) { sum += l[up][left]; if (l[up][left] == 0) { br = true; break; } } if (br) break; } if (br) continue; mx = max(sum, mx); } } cout << mx; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...