# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
37926 | Talant | UFO (IZhO14_ufo) | C++11 | 2000 ms | 9708 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 <bits/stdc++.h>
#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
const int inf = (int)1e9 + 7;
const int N = (int)1e6 + 7;
int n,m,r,k,p;
int mx = 0;
int main () {
cin >> 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 ++)
cin >> a[i][j];
while (k --) {
char ch;
int l,bl,cnt = 0;
cin >> ch;
scanf ("%d%d", &l,&bl);
if (ch == 'N') {
cnt = 0;
for (int i = 1; i <= n; i ++) {
if (a[i][l] >= bl)
a[i][l] --,cnt ++;
if (cnt == r)
break;
}
}
else if (ch == 'W') {
cnt = 0;
for (int i = 1; i <= m; i ++) {
if (a[l][i] >= bl)
a[l][i] --,cnt ++;
if (cnt == r)
break;
}
}
else if (ch == 'E') {
cnt = 0;
for (int i = m; i >= 1; i --) {
if (a[l][i] >= bl)
a[l][i] --,cnt ++;
if (cnt == r)
break;
}
}
else {
cnt = 0;
for (int i = n; i >= 1; i --) {
if (a[i][l] >= bl)
a[i][l] --,cnt ++;
if (cnt == r)
break;
}
}
}
for (int i = 1; i <= n; i ++)
for (int j = 2; j <= m; j ++)
a[i][j] += a[i][j - 1];
for (int i = 2; i <= n; i ++)
for (int j = 1; j <= m; j ++)
a[i][j] += a[i - 1][j];
for (int i = 1; i <= n; i ++)
a[i][0] = 0;
for (int j = 0; j <= m; j ++)
a[0][j] = 0;
for (int i = p; i <= n; i ++)
for (int j = p; j <= m; j ++) {
mx = max(mx,a[i][j] - a[i - p][j] - a[i][j - p] + a[i - p][j - p]);
}
cout << mx << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |