/** kutbilim.one **/
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define int long long
#define endl '\n'
/*
ifstream in("test.txt");
#define cin in */
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, r, k, p;
cin >> n >> m >> r >> k >> p;
vector< vector<int> > a(n+1, vector<int>(m+1));
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++) cin >> a[i][j];
while(k--){
char side;
int pos, h;
cin >> side >> pos >> h;
int shots = r;
if(side == 'W'){
for(int j = 1; j <= m && shots > 0; j++)
while(a[pos][j] >= h) a[pos][j]--, shots--;
}else if(side == 'E'){
for(int j = m; j >= 1 && shots > 0; j--)
while(a[pos][j] >= h) a[pos][j]--, shots--;
}else if(side == 'N'){
for(int i = 1; i <= n && shots > 0; i++)
while(a[i][pos] >= h) a[i][pos]--, shots--;
}else{
for(int i = n; i >= 1 && shots > 0; i--)
while(a[i][pos] >= h) a[i][pos]--, shots--;
}
}
vector< vector<int> > sums(n+2, vector<int>(m+1));
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
sums[i][j] += a[i][j] + sums[i][j-1];
}
}
for(int i = 1; i <= m; i++){
for(int j = 1; j <= n; j++){
sums[j][i] += sums[j-1][i];
}
}
int maxx = 0;
for(int i = p; i <= n; i++){
for(int j = p; j <= m; j++){
maxx = max(maxx, sums[i][j]-sums[i][j-p]-sums[i-p][j]+sums[i-p][j-p]);
}
}
cout << maxx;
return 0;
}
Compilation message
ufo.cpp: In function 'int main()':
ufo.cpp:21:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
21 | for(int i = 1; i <= n; i++)
| ^~~
ufo.cpp:25:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
25 | while(k--){
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
9 ms |
620 KB |
Output isn't correct |
5 |
Incorrect |
363 ms |
1972 KB |
Output isn't correct |
6 |
Incorrect |
652 ms |
9708 KB |
Output isn't correct |
7 |
Execution timed out |
2086 ms |
10460 KB |
Time limit exceeded |
8 |
Execution timed out |
2081 ms |
10460 KB |
Time limit exceeded |
9 |
Execution timed out |
2073 ms |
10084 KB |
Time limit exceeded |
10 |
Execution timed out |
2049 ms |
10588 KB |
Time limit exceeded |
11 |
Execution timed out |
2051 ms |
10432 KB |
Time limit exceeded |
12 |
Execution timed out |
2045 ms |
10460 KB |
Time limit exceeded |
13 |
Execution timed out |
2079 ms |
13676 KB |
Time limit exceeded |
14 |
Execution timed out |
2075 ms |
10304 KB |
Time limit exceeded |
15 |
Execution timed out |
2071 ms |
10460 KB |
Time limit exceeded |
16 |
Execution timed out |
2078 ms |
10304 KB |
Time limit exceeded |
17 |
Execution timed out |
2070 ms |
13548 KB |
Time limit exceeded |
18 |
Execution timed out |
2071 ms |
14060 KB |
Time limit exceeded |
19 |
Execution timed out |
2041 ms |
11372 KB |
Time limit exceeded |
20 |
Execution timed out |
2069 ms |
23788 KB |
Time limit exceeded |