답안 #388528

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

using namespace std;

#define int long long

const int INF = 0x3f3f3f3f3f3f3f;

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 4 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 4 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Incorrect 4 ms 8140 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 4 ms 8140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 4 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Incorrect 4 ms 8140 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 4 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Incorrect 4 ms 8140 KB Output isn't correct
8 Halted 0 ms 0 KB -