#include<bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define ll long long
#define pb push_back
#define nl '\n'
#define popb pop_back()
#define sz size()
#define ld long double
#define ull unsigned long long
#define F first
#define S second
#define fix fixed<<setprecision
#define pii pair<int,int>
#define E exit (0)
#define int long long
const int inf=1e9;
signed main() {
//freopen("planting.in","r",stdin);
//freopen("planting.out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m,r,k,p;
cin>>n>>m>>r>>k>>p;
int c[n+1][m+1];
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) {
cin>>c[i][j];
}
}
for (int i=1;i<=k;i++) {
char x;
int a,b;
cin>>x>>a>>b;
if (x=='W') {
for (int j=1,R=r;j<=m&&R>0;j++) {
if (c[a][j]>=b) {
c[a][j]--;
R--;
}
}
}
if (x=='N') {
for (int j=1,R=r;j<=n&&R>0;j++) {
if (c[j][a]>=b) {
c[j][a]--;
R--;
}
}
}
if (x=='E') {
for (int j=m,R=r;j>=1&&R>0;j--) {
if (c[a][j]>=b) {
c[a][j]--;
R--;
}
}
}
if (x=='S') {
for (int j=n,R=r;j>=1&&R>0;j--) {
if (c[j][a]>=b) {
c[j][a]--;
R--;
}
}
}
}
int mx=0;
int pp[n+1][m+1];
for (int i=1;i<=n;i++) {
pp[i][0]=0;
for (int j=1;j<=m;j++) {
pp[i][j]=pp[i][j-1]+c[i][j];
if (i>=p&&j>=p) {
int sum=0;
for (int i1=i-p+1;i1<=i;i1++) {
sum+=pp[i1][j]-pp[i1][j-p];
}
mx=max(mx,sum);
}
}
}
cout<<mx;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
5 ms |
492 KB |
Output is correct |
5 |
Correct |
15 ms |
1132 KB |
Output is correct |
6 |
Correct |
87 ms |
7984 KB |
Output is correct |
7 |
Execution timed out |
2017 ms |
8092 KB |
Time limit exceeded |
8 |
Execution timed out |
2044 ms |
8320 KB |
Time limit exceeded |
9 |
Execution timed out |
2035 ms |
8176 KB |
Time limit exceeded |
10 |
Execution timed out |
2053 ms |
8220 KB |
Time limit exceeded |
11 |
Execution timed out |
2061 ms |
7788 KB |
Time limit exceeded |
12 |
Execution timed out |
2013 ms |
8204 KB |
Time limit exceeded |
13 |
Execution timed out |
2086 ms |
8940 KB |
Time limit exceeded |
14 |
Correct |
1535 ms |
15340 KB |
Output is correct |
15 |
Execution timed out |
2083 ms |
8220 KB |
Time limit exceeded |
16 |
Execution timed out |
2072 ms |
7788 KB |
Time limit exceeded |
17 |
Execution timed out |
2052 ms |
8888 KB |
Time limit exceeded |
18 |
Execution timed out |
2027 ms |
7936 KB |
Time limit exceeded |
19 |
Execution timed out |
2059 ms |
8172 KB |
Time limit exceeded |
20 |
Execution timed out |
2037 ms |
8172 KB |
Time limit exceeded |