Submission #44908

# Submission time Handle Problem Language Result Execution time Memory
44908 2018-04-09T09:24:17 Z ulna Maxcomp (info1cup18_maxcomp) C++11
100 / 100
194 ms 4816 KB
#include <bits/stdc++.h>
using namespace std;

// why am I so weak

int n, m;
int a[1055][1055];
int dp[1055];

int solve() {
	int res = -INT_MAX;

	for (int j = 0; j < m; j++) {
		dp[j] = -(int)1e9;
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			dp[j]--;
		}

		{
			int roll = -(int)1e9;

			for (int j = 0; j < m; j++) {
				roll--;
				roll = max(roll, -a[i][j] - 1);

				dp[j] = max(dp[j], roll);
			}
		}

		{
			int roll = -(int)1e9;

			for (int j = m - 1; j >= 0; j--) {
				roll--;
				roll = max(roll, -a[i][j] - 1);

				dp[j] = max(dp[j], roll);
			}
		}

		for (int j = 0; j < m; j++) {
			res = max(res, a[i][j] + dp[j]);
		}
	}

	return res;
}
int main() {
	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
		scanf("%d", &a[i][j]);
	}

	int res = -1;

	res = max(res, solve());

	for (int i = 0; i < n / 2; i++) {
		swap(a[i], a[n - i - 1]);
	}

	res = max(res, solve());

	cout << res << endl;

	return 0;
}

Compilation message

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
maxcomp.cpp:55:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i][j]);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 680 KB Output is correct
5 Correct 2 ms 680 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 680 KB Output is correct
2 Correct 2 ms 680 KB Output is correct
3 Correct 2 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 680 KB Output is correct
5 Correct 2 ms 680 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 3 ms 704 KB Output is correct
10 Correct 2 ms 704 KB Output is correct
11 Correct 3 ms 704 KB Output is correct
12 Correct 3 ms 704 KB Output is correct
13 Correct 2 ms 720 KB Output is correct
14 Correct 2 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 680 KB Output is correct
5 Correct 2 ms 680 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 3 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 3 ms 704 KB Output is correct
15 Correct 3 ms 704 KB Output is correct
16 Correct 2 ms 720 KB Output is correct
17 Correct 2 ms 720 KB Output is correct
18 Correct 191 ms 4816 KB Output is correct
19 Correct 186 ms 4816 KB Output is correct
20 Correct 175 ms 4816 KB Output is correct
21 Correct 194 ms 4816 KB Output is correct
22 Correct 184 ms 4816 KB Output is correct
23 Correct 187 ms 4816 KB Output is correct
24 Correct 147 ms 4816 KB Output is correct