답안 #359172

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
359172 2021-01-26T12:02:55 Z Mlxa Maxcomp (info1cup18_maxcomp) C++14
60 / 100
500 ms 17004 KB
#ifdef LC
#include "pch.h"
#else
#include <bits/stdc++.h>
#endif
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

const int N = 1 << 10;
const int INF = 1e18;

int n;
int m;
int a[N][N];

void rot() {
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			swap(a[i][j], a[j][i]);
		}
	}
	swap(n, m);
	for (int i = 0; i < n; ++i) {
		reverse(a[i], a[i] + m);
	}
}

int answer = -1;

int t[2 * N];

void clear() {
	fill_n(t, 2 * N, INF);
}

void update(int i, int v) {
	i += N;
	t[i] = min(t[i], v);
	for (i /= 2; i > 0; i /= 2) {
		t[i] = min(t[i + i], t[i + i + 1]);
	}
}

int query(int l, int r) {
	int res = INF;
	for (l += N, r += N; l <= r; l /= 2, r /= 2) {
		if (l % 2 == 1) {
			res = min(res, t[l++]);
		}
		if (r % 2 == 0) {
			res = min(res, t[r--]);
		}
	}
	return res;
}

void solve() {
	clear();
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			// answer = max(answer, a[i][j] - i - j - 1 - query(0, j));
			// update(j, a[i][j] + i + j);
			for (int ii = 0; ii <= i; ++ii) {
				for (int jj = 0; jj <= j; ++jj) {
					answer = max(answer, a[i][j] - a[ii][jj] - (i + j - ii - jj + 1));
				}
			}
		}
	}
}

signed main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif
    ios::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 it = 0; it < 4; ++it) {
    	if (it) {
    		rot();
    	}
    	solve();
    }
    cout << answer << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 8556 KB Output is correct
2 Correct 27 ms 8556 KB Output is correct
3 Correct 26 ms 8556 KB Output is correct
4 Correct 26 ms 8556 KB Output is correct
5 Correct 26 ms 8556 KB Output is correct
6 Correct 26 ms 8556 KB Output is correct
7 Correct 26 ms 8556 KB Output is correct
8 Correct 27 ms 8556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 8616 KB Output is correct
2 Correct 34 ms 8576 KB Output is correct
3 Correct 36 ms 8568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 8556 KB Output is correct
2 Correct 27 ms 8556 KB Output is correct
3 Correct 26 ms 8556 KB Output is correct
4 Correct 26 ms 8556 KB Output is correct
5 Correct 26 ms 8556 KB Output is correct
6 Correct 26 ms 8556 KB Output is correct
7 Correct 26 ms 8556 KB Output is correct
8 Correct 27 ms 8556 KB Output is correct
9 Correct 39 ms 8684 KB Output is correct
10 Correct 40 ms 8556 KB Output is correct
11 Correct 38 ms 8556 KB Output is correct
12 Correct 35 ms 8556 KB Output is correct
13 Correct 41 ms 8556 KB Output is correct
14 Correct 38 ms 8556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 8556 KB Output is correct
2 Correct 27 ms 8556 KB Output is correct
3 Correct 26 ms 8556 KB Output is correct
4 Correct 26 ms 8556 KB Output is correct
5 Correct 26 ms 8556 KB Output is correct
6 Correct 26 ms 8556 KB Output is correct
7 Correct 26 ms 8556 KB Output is correct
8 Correct 27 ms 8556 KB Output is correct
9 Correct 37 ms 8616 KB Output is correct
10 Correct 34 ms 8576 KB Output is correct
11 Correct 36 ms 8568 KB Output is correct
12 Correct 39 ms 8684 KB Output is correct
13 Correct 40 ms 8556 KB Output is correct
14 Correct 38 ms 8556 KB Output is correct
15 Correct 35 ms 8556 KB Output is correct
16 Correct 41 ms 8556 KB Output is correct
17 Correct 38 ms 8556 KB Output is correct
18 Execution timed out 1082 ms 17004 KB Time limit exceeded
19 Halted 0 ms 0 KB -