// turmak-_-
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define int long long
#define sz(a) a.size()
#define nl "\n"
#define IOI return 0;
#define pb push_back
#define ppb pop_back()
#define ull unsigned long long
#define ld long double
#define IOS ios_base :: sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define X first
#define Y second
using namespace std;
const int N = (int)1e5 + 7 ;
const int MOD = (int)998244353;
const int INF = (int)1e18 + 7;
const int inf = (int)1e9 + 7;
pii dx[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
void solve() {
int n,m,r,k,p;
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 tp;
int x,y;
cin>>tp>>x>>y;
int cnt = 1;
if(tp=='N') {
for(int i=1; i<=n; ++i) {
if(cnt>r) break;
if(a[i][x]>=y) {
if(cnt<=r) {
a[i][x]--;
cnt++;
}
}
}
}
if(tp=='W') {
for(int i=1; i<=m; ++i) {
if(cnt>r) break;
if(a[x][i]>=y) {
if(cnt<=r) {
a[x][i]--;
cnt++;
}
}
}
}
if(tp=='S') {
for(int i=n; i>=1; --i) {
if(cnt>r) break;
if(a[i][x]>=y) {
if(cnt<=r) {
a[i][x]--;
cnt++;
}
}
}
}
if(tp=='E') {
for(int i=m; i>=1; --i) {
if(cnt>r) break;
if(a[x][i]>=y) {
if(cnt<=r) {
a[x][i]--;
cnt++;
}
}
}
}
}
int mx = 0;
for(int i=1; i<=n-p+1; ++i) {
for(int j=1; j<=m-p+1; ++j) {
int x = i, y = j, sum=0;
for(int ii = x; ii<=x+p-1; ++ii) {
for(int jj = y; jj<=y+p-1; ++jj) {
sum+=a[ii][jj];
}
}
mx = max(mx, sum);
}
}
cout<<mx<<nl;
}
signed main() {
IOS
srand(time(0));
//freopen("cinema.in", "r", stdin);
//freopen("cinema.out", "w", stdout);
int tt=1;
//cin>>tt;
while(tt--) {
solve();
}
IOI
}
# |
결과 |
실행 시간 |
메모리 |
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 |
7 ms |
492 KB |
Output is correct |
5 |
Correct |
25 ms |
1388 KB |
Output is correct |
6 |
Correct |
90 ms |
6124 KB |
Output is correct |
7 |
Execution timed out |
2063 ms |
10508 KB |
Time limit exceeded |
8 |
Execution timed out |
2019 ms |
9564 KB |
Time limit exceeded |
9 |
Execution timed out |
2023 ms |
10032 KB |
Time limit exceeded |
10 |
Execution timed out |
2029 ms |
10004 KB |
Time limit exceeded |
11 |
Execution timed out |
2019 ms |
9244 KB |
Time limit exceeded |
12 |
Execution timed out |
2067 ms |
10348 KB |
Time limit exceeded |
13 |
Execution timed out |
2063 ms |
11156 KB |
Time limit exceeded |
14 |
Correct |
1499 ms |
10220 KB |
Output is correct |
15 |
Execution timed out |
2059 ms |
10524 KB |
Time limit exceeded |
16 |
Execution timed out |
2092 ms |
9196 KB |
Time limit exceeded |
17 |
Execution timed out |
2062 ms |
11556 KB |
Time limit exceeded |
18 |
Execution timed out |
2078 ms |
9188 KB |
Time limit exceeded |
19 |
Execution timed out |
2075 ms |
9680 KB |
Time limit exceeded |
20 |
Execution timed out |
2066 ms |
9740 KB |
Time limit exceeded |