Submission #67022

# Submission time Handle Problem Language Result Execution time Memory
67022 2018-08-13T08:34:09 Z cdemirer Maxcomp (info1cup18_maxcomp) C++17
0 / 100
2 ms 596 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<vi> vvi;
typedef pair<double, double> dodo;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

int N, M;
int input[3000][3000];
int mat[3000][3000];
int solve() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			mat[i][j] = input[i][j] - (i+j);
		}
	}
	for (int i = N-2; i >= 0; i--) {
		for (int j = M-2; j >= 0; j--) {
			mat[i][j] = max(mat[i+1][j], mat[i][j+1]);
		}
	}
	int ret = -1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			ret = max(ret, mat[i][j] - input[i][j] + (i+j) - 1);
		}
	}
	return ret;
}

int main(int argc, char **argv) {
	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 >> input[i][j];
		}
	}
	
	int ans = solve();
	for (int i = 0; i < N/2; i++) {
		for (int j = 0; j < M; j++) {
			swap(input[i][j], input[N-1-i][j]);
		}
	}
	ans = max(ans, solve());
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			input[i][j] = -input[i][j];
		}
	}
	ans = max(ans, solve());
	for (int i = 0; i < N/2; i++) {
		for (int j = 0; j < M; j++) {
			swap(input[i][j], input[N-1-i][j]);
		}
	}
	ans = max(ans, solve());
	cout << ans << endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Incorrect 2 ms 596 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Incorrect 2 ms 596 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Incorrect 2 ms 596 KB Output isn't correct
5 Halted 0 ms 0 KB -