답안 #872961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872961 2023-11-14T07:43:45 Z TAhmed33 Zemljište (COCI22_zemljiste) C++
30 / 70
2000 ms 4700 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll pref[501][501], n, m, a, b;
ll dist (ll x) {
	return abs(x - a) + abs(x - b);
}
int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> a >> b;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> pref[i][j]; pref[i][j] += pref[i - 1][j];
		}
	}
	ll mn = 1e18;
	for (int l = 1; l <= n; l++) {
		for (int r = l; r <= n; r++) {
			ll arr[m + 1] = {};
			for (int j = 1; j <= m; j++) {
				arr[j] = pref[r][j] - pref[l - 1][j];
				arr[j] += arr[j - 1];
			}
			for (int i = 0; i <= m; i++) {
				for (int j = i + 1; j <= m; j++) {
					mn = min(mn, dist(arr[j] - arr[i]));
				}
			}
		}
	}
	cout << mn << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 15 ms 784 KB Output is correct
11 Correct 46 ms 860 KB Output is correct
12 Correct 44 ms 856 KB Output is correct
13 Correct 45 ms 928 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 43 ms 928 KB Output is correct
16 Correct 45 ms 1112 KB Output is correct
17 Correct 47 ms 872 KB Output is correct
18 Correct 47 ms 860 KB Output is correct
19 Correct 46 ms 652 KB Output is correct
20 Correct 50 ms 880 KB Output is correct
21 Correct 43 ms 860 KB Output is correct
22 Correct 45 ms 884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 15 ms 784 KB Output is correct
11 Correct 46 ms 860 KB Output is correct
12 Correct 44 ms 856 KB Output is correct
13 Correct 45 ms 928 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 43 ms 928 KB Output is correct
16 Correct 45 ms 1112 KB Output is correct
17 Correct 47 ms 872 KB Output is correct
18 Correct 47 ms 860 KB Output is correct
19 Correct 46 ms 652 KB Output is correct
20 Correct 50 ms 880 KB Output is correct
21 Correct 43 ms 860 KB Output is correct
22 Correct 45 ms 884 KB Output is correct
23 Execution timed out 2078 ms 4700 KB Time limit exceeded
24 Halted 0 ms 0 KB -