답안 #1032109

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032109 2024-07-23T11:50:29 Z juicy Growing Vegetables is Fun 4 (JOI21_ho_t1) C++17
100 / 100
22 ms 7008 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int N = 2e5 + 5;
const long long inf = 1e18;

int n;
int a[N], d[N];
long long pf[N], sf[N];

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i < n; ++i) {
		d[i] = a[i] - a[i + 1];
	}
	for (int i = 1; i < n; ++i) {
		pf[i] = pf[i - 1] +  max(0, d[i] + 1);
	}
	for (int i = n - 1; i >= 1; --i) {
		sf[i] = sf[i + 1] + max(0, -d[i] + 1);
	}
	long long res = inf;
	for (int i = 1; i <= n; ++i) {
		res = min(res, max(pf[i - 1], sf[i]));
	}
	cout << res;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2520 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2524 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2540 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2532 KB Output is correct
19 Correct 0 ms 2520 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2536 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2520 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2524 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2540 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2532 KB Output is correct
19 Correct 0 ms 2520 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2536 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2524 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 20 ms 6900 KB Output is correct
27 Correct 20 ms 7004 KB Output is correct
28 Correct 17 ms 6984 KB Output is correct
29 Correct 15 ms 7004 KB Output is correct
30 Correct 12 ms 6160 KB Output is correct
31 Correct 16 ms 6992 KB Output is correct
32 Correct 15 ms 7004 KB Output is correct
33 Correct 16 ms 7000 KB Output is correct
34 Correct 15 ms 6920 KB Output is correct
35 Correct 12 ms 6236 KB Output is correct
36 Correct 16 ms 6232 KB Output is correct
37 Correct 16 ms 6236 KB Output is correct
38 Correct 16 ms 7004 KB Output is correct
39 Correct 16 ms 6996 KB Output is correct
40 Correct 22 ms 7004 KB Output is correct
41 Correct 15 ms 7004 KB Output is correct
42 Correct 14 ms 6744 KB Output is correct
43 Correct 15 ms 7004 KB Output is correct
44 Correct 15 ms 6924 KB Output is correct
45 Correct 15 ms 7000 KB Output is correct
46 Correct 19 ms 7004 KB Output is correct
47 Correct 15 ms 7004 KB Output is correct
48 Correct 15 ms 7008 KB Output is correct