# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91112 | inom | UFO (IZhO14_ufo) | C++14 | 13 ms | 604 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 <stdio.h>
#define fi first
#define se second
#define pb push_back
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define in freopen("ufo.in", "r", stdin);
#define out freopen("ufo.out", "w", stdout);
using namespace std;
const int N = 100100;
const int MOD = 1e9;
int TN = 1;
int n, m, r, k, p;
void solve() {
scanf("%d %d %d %d %d", &n, &m, &r, &k, &p);
int a[n + 1][m + 1];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
scanf("%d ", &a[i][j]);
}
}
for (int i = 1; i <= k; i++) {
char c; int x, h;
if (i == k) {
scanf("%c %d %d", &c, &x, &h);
}
else {
scanf("%c %d %d\n", &c, &x, &h);
}
if (c == 'W' || c == 'E') {
if (c == 'W') {
int cnt = r, j = 1;
while (j <= m && cnt > 0) {
if (a[x][j] >= h) {
a[x][j]--; cnt--;
}
j++;
}
}
else {
int cnt = r, j = m;
while (j >= 1 && cnt > 0) {
if (a[x][j] >= h) {
a[x][j]--; cnt--;
}
j--;
}
}
}
else {
if (c == 'N') {
int cnt = r, j = 1;
while (j <= n && cnt > 0) {
if (a[j][x] >= h) {
a[j][x]--; cnt--;
}
j++;
}
}
else {
int cnt = r, j = n;
while (j >= 1 && cnt > 0) {
if (a[j][x] >= h) {
a[j][x]--; cnt--;
}
j--;
}
}
}
}
int ans = 0; p--;
for (int i = 1; i + p <= n; i++) {
for (int j = 1; j + p <= m; j++) {
int sum = 0;
for (int u = i; u <= i + p; u++) {
for (int v = j; v <= j + p; v++) {
sum += a[u][v];
}
}
if (ans < sum) {
ans = sum;
}
}
}
printf("%d\n", ans);
return;
}
signed main() {
// ios_base::sync_with_stdio(0);
in; out; // cin >> TN;
while (TN--) solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |