Submission #46791

# Submission time Handle Problem Language Result Execution time Memory
46791 2018-04-23T09:46:58 Z jun6873 Maxcomp (info1cup18_maxcomp) C++11
100 / 100
165 ms 8456 KB
#include <bits/stdc++.h>
using namespace std;

int h, w, a[1004][1004], mx[1004][1004];

int solve() {
	for (int i=0; i<=h; i++) for (int j=0; j<=w; j++) mx[i][j] = -2e9;
	int ret = -1;
	for (int i=1; i<=h; i++) for (int j=1; j<=w; j++) {
		int k = i + j - a[i][j];
		mx[i][j] = max({mx[i-1][j], mx[i][j-1], k});
		ret = max(ret, mx[i][j] - k - 1);
	}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> h >> w;
	for (int i=1; i<=h; i++) for (int j=1; j<=w; j++)
		cin >> a[i][j];

	int ans = solve();
	for (int i=1; i<=h; i++) for (int j=1; j<=w/2; j++) swap(a[i][j], a[i][w-j+1]);
	ans = max(ans, solve());
	for (int i=1; i<=h/2; i++) for (int j=1; j<=w; j++) swap(a[i][j], a[h-i+1][j]);
	ans = max(ans, solve());
	for (int i=1; i<=h; i++) for (int j=1; j<=w/2; j++) swap(a[i][j], a[i][w-j+1]);
	ans = max(ans, solve());

	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 536 KB Output is correct
5 Correct 2 ms 644 KB Output is correct
6 Correct 2 ms 644 KB Output is correct
7 Correct 2 ms 644 KB Output is correct
8 Correct 2 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 644 KB Output is correct
2 Correct 2 ms 648 KB Output is correct
3 Correct 2 ms 648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 536 KB Output is correct
5 Correct 2 ms 644 KB Output is correct
6 Correct 2 ms 644 KB Output is correct
7 Correct 2 ms 644 KB Output is correct
8 Correct 2 ms 644 KB Output is correct
9 Correct 3 ms 1032 KB Output is correct
10 Correct 2 ms 1032 KB Output is correct
11 Correct 3 ms 1032 KB Output is correct
12 Correct 2 ms 1032 KB Output is correct
13 Correct 3 ms 1032 KB Output is correct
14 Correct 2 ms 1032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 536 KB Output is correct
5 Correct 2 ms 644 KB Output is correct
6 Correct 2 ms 644 KB Output is correct
7 Correct 2 ms 644 KB Output is correct
8 Correct 2 ms 644 KB Output is correct
9 Correct 2 ms 644 KB Output is correct
10 Correct 2 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 3 ms 1032 KB Output is correct
13 Correct 2 ms 1032 KB Output is correct
14 Correct 3 ms 1032 KB Output is correct
15 Correct 2 ms 1032 KB Output is correct
16 Correct 3 ms 1032 KB Output is correct
17 Correct 2 ms 1032 KB Output is correct
18 Correct 165 ms 8456 KB Output is correct
19 Correct 155 ms 8456 KB Output is correct
20 Correct 145 ms 8456 KB Output is correct
21 Correct 143 ms 8456 KB Output is correct
22 Correct 148 ms 8456 KB Output is correct
23 Correct 142 ms 8456 KB Output is correct
24 Correct 146 ms 8456 KB Output is correct