Submission #345207

#TimeUsernameProblemLanguageResultExecution timeMemory
345207mansurUFO (IZhO14_ufo)C++14
35 / 100
2086 ms15340 KiB
#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 timeMemoryGrader output
Fetching results...