Submission #337347

#TimeUsernameProblemLanguageResultExecution timeMemory
337347boykutUFO (IZhO14_ufo)C++14
25 / 100
2083 ms10572 KiB
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, k, r, p; cin >> n >> m >> r >> k >> p; int a[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } for (int i = 0; i < k; i++) { char ch; cin >> ch; int pos, h; cin >> pos >> h; pos--; if (ch == 'N') { int cnt = 0; for (int i = 0; i < n; i++) { if (a[i][pos] >= h) { a[i][pos] --; cnt++; if (cnt == r) break; } } } else if (ch == 'E') { int cnt = 0; for (int i = m - 1; i >= 0; i--) { if (a[pos][i] >= h) { a[pos][i] --; cnt++; if (cnt == r) break; } } } else if (ch == 'W') { int cnt = 0; for (int i = 0; i < m; i++) { if (a[pos][i] >= h) { a[pos][i] --; cnt++; if (cnt == r) break; } } } else { for (int i = n - 1; i >= 0; i--) { int cnt = 0; if (a[i][pos] >= h) { a[i][pos] --; cnt++; if (cnt == r) break; } } } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { //cout << a[i][j] << ' '; } //cout << '\n'; } int sum = 0, ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (i + p <= n && j + p <= m) { sum = 0; for (int i1 = i; i1 < i + p; i1++) { for (int j1 = j; j1 < j + p; j1++) { sum += a[i1][j1]; } } if (sum > ans) { //cout << i << ' ' << j << '\n'; ans = sum; //cout << sum << "\n\n"; } } } } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...