#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
ufo.cpp: In function 'int main()':
ufo.cpp:32:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d%d", &l,&bl);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2016 KB |
Output is correct |
2 |
Correct |
0 ms |
2016 KB |
Output is correct |
3 |
Correct |
0 ms |
2016 KB |
Output is correct |
4 |
Correct |
6 ms |
2016 KB |
Output is correct |
5 |
Correct |
36 ms |
2104 KB |
Output is correct |
6 |
Correct |
243 ms |
3812 KB |
Output is correct |
7 |
Execution timed out |
2000 ms |
6192 KB |
Execution timed out |
8 |
Execution timed out |
2000 ms |
6188 KB |
Execution timed out |
9 |
Execution timed out |
2000 ms |
5992 KB |
Execution timed out |
10 |
Execution timed out |
2000 ms |
6192 KB |
Execution timed out |
11 |
Execution timed out |
2000 ms |
6108 KB |
Execution timed out |
12 |
Execution timed out |
2000 ms |
6188 KB |
Execution timed out |
13 |
Execution timed out |
2000 ms |
6192 KB |
Execution timed out |
14 |
Correct |
1736 ms |
6108 KB |
Output is correct |
15 |
Execution timed out |
2000 ms |
6192 KB |
Execution timed out |
16 |
Execution timed out |
2000 ms |
6108 KB |
Execution timed out |
17 |
Execution timed out |
2000 ms |
6188 KB |
Execution timed out |
18 |
Execution timed out |
2000 ms |
5640 KB |
Execution timed out |
19 |
Execution timed out |
2000 ms |
6584 KB |
Execution timed out |
20 |
Execution timed out |
2000 ms |
9708 KB |
Execution timed out |