Submission #345331

# Submission time Handle Problem Language Result Execution time Memory
345331 2021-01-07T07:36:27 Z l3nl3 UFO (IZhO14_ufo) C++14
10 / 100
163 ms 42732 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>  
 
#define exit exit(false)
 
//#define here() cerr << "herewego\n";
#define show(x) cerr << #x << ": " << x << '\n';
 
#define int long long
//#define double long double
 
#define all(a) a.begin(), a.end()
#define whole(a, p, q) a+p, a+p+q
 
#define ioio() ios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0);
 
using namespace std;
 
//using namespace __gnu_pbds;   
//typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;  

const int mxsz = 1e4 + 7;

int n, m, r, k , p, a[mxsz][mxsz], pr[mxsz][mxsz], mx;
char tp;
int x, y, h, sum, cn;

signed main () { ioio();
	cin >> n >> m >> r >> k >> p;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
			sum += a[i][j];
		}
	}
	while (k--) {
		cin >> tp >> x >> h;
		x++;
		cn = r;
		y = 1;
		if (tp == 'N') {
			while (y <= n && cn > 0) {
				if (a[y][x] >= h) {
					a[y][x]--;
					cn--;
				}
				y++;
			}
		} else if (tp == 'W') {
			while (y <= n && cn > 0) {
				if (a[x][y] >= h) {
					a[x][y]--;
					cn--;
				}
				y++;
			}
		} else if (tp == 'S') {
			while (y <= n && cn > 0) {
				if (a[y][x] >= h) {
					a[y][x]--;
					cn--;
				}
				y++;
			}
		} else {
			while (y <= n && cn > 0) {
				if (a[x][y] >= h) {
					a[x][y]--;
					cn--;
				}
				y++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			pr[i][j] = pr[i-1][j] + a[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			int pj = j;
			int sum = 0;
			while ((pj - j + 1) <= p) {
				sum += pr[i+(p-1)][pj] - pr[i-1][pj];
				pj++;
			}
			mx = max (mx, sum);
		}
	}
	cout << mx;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 396 KB Output isn't correct
3 Incorrect 2 ms 748 KB Output isn't correct
4 Incorrect 5 ms 1388 KB Output isn't correct
5 Incorrect 22 ms 1264 KB Output isn't correct
6 Incorrect 75 ms 13804 KB Output isn't correct
7 Incorrect 152 ms 4076 KB Output isn't correct
8 Incorrect 142 ms 4128 KB Output isn't correct
9 Incorrect 129 ms 4716 KB Output isn't correct
10 Incorrect 100 ms 3920 KB Output isn't correct
11 Incorrect 96 ms 3948 KB Output isn't correct
12 Incorrect 107 ms 3692 KB Output isn't correct
13 Runtime error 74 ms 42732 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Incorrect 96 ms 3308 KB Output isn't correct
15 Incorrect 118 ms 4260 KB Output isn't correct
16 Incorrect 133 ms 4076 KB Output isn't correct
17 Runtime error 69 ms 42604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 76 ms 42476 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Incorrect 136 ms 4920 KB Output isn't correct
20 Correct 163 ms 16748 KB Output is correct