# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
345207 | mansur | UFO (IZhO14_ufo) | C++14 | 2086 ms | 15340 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<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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |