# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
17460 | azecoder | UFO (IZhO14_ufo) | C++98 | 0 ms | 2016 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 <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <memory.h>
#include <queue>
#include <cmath>
#include <map>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000
#define MOD 1000000
using namespace std;
int N, M, R, K, P, x, h, ans;
char ch;
int main()
{
freopen("ufo.in", "r", stdin);
freopen("ufo.out", "w", stdout);
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]);
int k = K;
while (k--) {
scanf(" %c %d %d", &ch, &x, &h);
int r = R;
if (ch == 'N') for (int i = 1; i <= N; i++) if (r && a[i][x] >= h) a[i][x]--, r--;
else if (!r) break;
if (ch == 'W') for (int i = 1; i <= M; i++) if (r && a[x][i] >= h) a[x][i]--, r--;
else if (!r) break;
if (ch == 'E') for (int i = M; i >= 1; i--) if (r && a[x][i] >= h) a[x][i]--, r--;
else if (!r) break;
if (ch == 'S') for (int i = N; i >= 1; i--) if (r && a[i][x] >= h) a[i][x]--, r--;
else if (!r) break;
}
for (int i = 1; i <= N - P + 1; i++)
for (int j = 1; j <= M - P + 1; j++) {
int c = 0;
for (int k = i; k < i + P; k++)
for (int l = j; l < j + P; l++)
c += a[k][l];
ans = max(ans, c);
}
cout << ans << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |