답안 #388527

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
388527 2021-04-12T01:29:31 Z warner1129 Maxcomp (info1cup18_maxcomp) C++17
15 / 100
3 ms 4172 KB
#include <bits/stdc++.h>

using namespace std;

const int INF = 0x3f3f3f3f;

struct bibit {
	static const int maxn = 1e3 + 5;
	int a[maxn][maxn] = {};
	int n, m;
	inline int lowbit(int x) { return x & (-x); }
	void init(int _n, int _m) {
		n = _n, m = _m;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				a[i][j] = INF;
	}
	void add(int x, int y, int v) {
		for (int i = x; i <= n; i += lowbit(i))
			for (int j = y; j <= m; j += lowbit(j))
				a[i][j] = min(a[i][j], v);
	}
	int que(int x, int y) {
		int ret = INF;
		for (int i = x; i > 0; i -= lowbit(i))
			for (int j = y; j > 0; j -= lowbit(j))
				ret = min(ret, a[i][j]);
		return ret;
	}
} bit;

const int maxn = 1e3 + 5;

long long G[maxn][maxn];

void solve() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> G[i][j];
	long long ans = 0;
	bit.init(n, m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			ans = max(ans, G[i][j] - i - j - bit.que(i, j));
			bit.add(i, j, G[i][j] - i - j);
		}
	bit.init(n, m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			ans = max(ans, G[i][m-j+1] - i - j - bit.que(i, j));
			bit.add(i, j, G[i][m-j+1] - i - j);
		}	
	cout << ans - 1 << '\n';
}

signed main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4172 KB Output is correct
2 Correct 2 ms 4172 KB Output is correct
3 Correct 2 ms 4172 KB Output is correct
4 Correct 2 ms 4172 KB Output is correct
5 Correct 2 ms 4172 KB Output is correct
6 Correct 2 ms 4172 KB Output is correct
7 Incorrect 2 ms 4172 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4172 KB Output is correct
2 Correct 2 ms 4172 KB Output is correct
3 Correct 3 ms 4172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4172 KB Output is correct
2 Correct 2 ms 4172 KB Output is correct
3 Correct 2 ms 4172 KB Output is correct
4 Correct 2 ms 4172 KB Output is correct
5 Correct 2 ms 4172 KB Output is correct
6 Correct 2 ms 4172 KB Output is correct
7 Incorrect 2 ms 4172 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4172 KB Output is correct
2 Correct 2 ms 4172 KB Output is correct
3 Correct 2 ms 4172 KB Output is correct
4 Correct 2 ms 4172 KB Output is correct
5 Correct 2 ms 4172 KB Output is correct
6 Correct 2 ms 4172 KB Output is correct
7 Incorrect 2 ms 4172 KB Output isn't correct
8 Halted 0 ms 0 KB -