Submission #317025

# Submission time Handle Problem Language Result Execution time Memory
317025 2020-10-29T01:08:21 Z 8e7 Maxcomp (info1cup18_maxcomp) C++14
60 / 100
500 ms 4228 KB
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define ll long long
#define pii pair<int, int>
#define maxn 1005
using namespace std;
int a[maxn][maxn], mi[maxn][maxn], ma[maxn][maxn];
int n, m;
inline int ab(int a) {
	return a > 0 ? a : -a;
}
/*
struct segtree {
	int seg[4 * maxn];
	void init(int cur, int l, int r, bool oper) {
		if (r <= l) return;
		if (r - l == 1) {
			seg[cur] = a[0][l];
			return;
		}
		int mid = (l + r) / 2;
		init(cur * 2, l, mid, oper);
		init(cur * 2 + 1, mid, r, oper);
		if (oper) seg[cur] = max(seg[cur * 2], seg[cur * 2 + 1]);
		else seg[cur] = min(seg[cur * 2], seg[cur * 2 + 1]);
	}
} s1, s2;
*/
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> m;
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < m;j++) cin >> a[i][j];
	}
	int ans = -(1<<30);
	for (int x1 = 0;x1 < n;x1++) {
		for (int x2 = 0;x2 < n;x2++) {
			for (int y1 = 0;y1 < m;y1++) {
				for (int y2 = 0;y2 < m;y2++) {
					int dist = ab(x2 - x1) + ab(y2 - y1) + 1;
					//cout << x1 << " " << y1 << " " << x2 << " " << y2 << ' ' << dist << endl;
					ans = max(ans, max(a[x1][y1], a[x2][y2]) - min(a[x1][y1], a[x2][y2]) - dist);
				}
			}
		}
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 23 ms 512 KB Output is correct
10 Correct 18 ms 512 KB Output is correct
11 Correct 18 ms 640 KB Output is correct
12 Correct 18 ms 512 KB Output is correct
13 Correct 18 ms 512 KB Output is correct
14 Correct 23 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 23 ms 512 KB Output is correct
13 Correct 18 ms 512 KB Output is correct
14 Correct 18 ms 640 KB Output is correct
15 Correct 18 ms 512 KB Output is correct
16 Correct 18 ms 512 KB Output is correct
17 Correct 23 ms 512 KB Output is correct
18 Execution timed out 1080 ms 4228 KB Time limit exceeded
19 Halted 0 ms 0 KB -