# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
17459 | azecoder | UFO (IZhO14_ufo) | C++98 | 2000 ms | 9704 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 <iostream>
#include <algorithm>
#define f first
#define s second
using namespace std;
int n , m , R , k , p , x, h, ans ;
char ch ;
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] ;
for ( int l = 0 ; l < k ; l ++ ) {
cin >> ch >> x >> h ;
int r = R ;
if ( ch == 'N' ) for ( int i = 1; i <= n; i ++ )
if ( r && a[i][x] >= h) a[i][x] --, r -- ;
else if ( !r ) break;
if ( ch == 'W' ) for ( int i = 1; i <= m; i ++ )
if ( r && a[x][i] >= h ) a[x][i] --, r -- ;
else if ( !r ) break;
if ( ch == 'E' ) for ( int i = n; i >= 1; i -- )
if ( r && a[x][i] >= h ) a[x][i] --, r -- ;
else if ( !r ) break;
if ( ch == 'S' ) for ( int i = m; i >= 1; i -- )
if ( r && a[i][x] >= h ) a[i][x] --, r -- ;
else if (!r) break;
}
for ( int i = 1 ; i <= n - p + 1 ; i ++ ) {
for ( int j = 1 ; j <= m - p + 1 ; j++) {
int c = 0;
for ( int k = i ; k < i + p ; k ++ )
for ( int l = j ; l < j + p ; l ++ )
c += a[k][l];
ans = max ( ans , c ) ;
}
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |