답안 #345203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
345203 2021-01-07T06:45:15 Z mansur UFO (IZhO14_ufo) C++14
35 / 100
2000 ms 15028 KB
#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;
	for (int i=1;i<=n;i++) {
    	for (int j=1;j<=m;j++) {
    		if (i>=p&&j>=p) {
    			int sum=0;
    			for (int i1=i-p+1;i1<=i;i1++) {
    				for (int j1=j-p+1;j1<=j;j1++) {
    					sum+=c[i1][j1];
    				}
    			}
    			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 6 ms 492 KB Output is correct
5 Correct 16 ms 1388 KB Output is correct
6 Correct 98 ms 7444 KB Output is correct
7 Execution timed out 2027 ms 14268 KB Time limit exceeded
8 Execution timed out 2047 ms 10908 KB Time limit exceeded
9 Execution timed out 2079 ms 11076 KB Time limit exceeded
10 Execution timed out 2045 ms 11164 KB Time limit exceeded
11 Execution timed out 2005 ms 10364 KB Time limit exceeded
12 Execution timed out 2075 ms 11420 KB Time limit exceeded
13 Execution timed out 2072 ms 12196 KB Time limit exceeded
14 Correct 1589 ms 11176 KB Output is correct
15 Execution timed out 2061 ms 11932 KB Time limit exceeded
16 Execution timed out 2047 ms 10356 KB Time limit exceeded
17 Execution timed out 2074 ms 15028 KB Time limit exceeded
18 Execution timed out 2037 ms 10092 KB Time limit exceeded
19 Execution timed out 2053 ms 10656 KB Time limit exceeded
20 Execution timed out 2097 ms 10348 KB Time limit exceeded