답안 #957633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957633 2024-04-04T06:33:12 Z peterandvoi Growing Vegetables is Fun 4 (JOI21_ho_t1) C++17
100 / 100
22 ms 7112 KB
#include <bits/stdc++.h>

using namespace std;

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

#define int long long

const int N = (int) 2e5 + 5;

int n;
int a[N];
int L[N], R[N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifdef ngu
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
    #endif
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (i > 1) {
            L[i] = L[i - 1] + max(0LL, a[i - 1] - a[i] + 1);
        }
    }
    for (int i = n - 1; i >= 1; --i) {
        R[i] = R[i + 1] + max(0LL, a[i + 1] - a[i] + 1);
    }
    const int INF = (int) 1e18;
    int res = INF;
    for (int i = 1; i <= n; ++i) {
        res = min(res, max(L[i], R[i]));
    }
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 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 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 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 2648 KB Output is correct
17 Correct 1 ms 2524 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2516 KB Output is correct
20 Correct 2 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2552 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 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 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 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 2648 KB Output is correct
17 Correct 1 ms 2524 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2516 KB Output is correct
20 Correct 2 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2552 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 20 ms 7004 KB Output is correct
27 Correct 21 ms 6860 KB Output is correct
28 Correct 19 ms 7004 KB Output is correct
29 Correct 20 ms 7004 KB Output is correct
30 Correct 14 ms 6236 KB Output is correct
31 Correct 17 ms 7000 KB Output is correct
32 Correct 17 ms 7000 KB Output is correct
33 Correct 18 ms 6860 KB Output is correct
34 Correct 17 ms 6964 KB Output is correct
35 Correct 14 ms 6240 KB Output is correct
36 Correct 15 ms 6232 KB Output is correct
37 Correct 15 ms 6236 KB Output is correct
38 Correct 17 ms 7060 KB Output is correct
39 Correct 18 ms 6996 KB Output is correct
40 Correct 17 ms 7112 KB Output is correct
41 Correct 17 ms 6980 KB Output is correct
42 Correct 22 ms 6812 KB Output is correct
43 Correct 17 ms 6992 KB Output is correct
44 Correct 17 ms 7008 KB Output is correct
45 Correct 17 ms 7048 KB Output is correct
46 Correct 17 ms 7004 KB Output is correct
47 Correct 17 ms 6996 KB Output is correct
48 Correct 17 ms 7064 KB Output is correct