답안 #316997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
316997 2020-10-29T00:45:25 Z 8e7 Maxcomp (info1cup18_maxcomp) C++14
15 / 100
6 ms 8192 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;
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];
	}
	for (int i = 0;i < m;i++) {
		int cur = a[0][i], c2 = a[0][i];
		for (int j = i;j < m;j++) {
			cur = max(cur, a[0][j]);
			ma[i][j] = cur;
			c2 = min(c2, a[0][j]);
			mi[i][j] = c2;
		}
	}
	int ans = 0;
	for (int i = 0;i < m;i++) {
		for (int j = i;j < m;j++) {
			ans = max(ans, ma[i][j] - mi[i][j] - (j - i + 1));
		}
	}
	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 416 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8192 KB Output is correct
2 Correct 6 ms 8192 KB Output is correct
3 Correct 6 ms 8192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 416 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 416 KB Output isn't correct
3 Halted 0 ms 0 KB -