# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1077316 | 2024-08-27T05:13:08 Z | quangminh412 | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++14 | 23 ms | 7080 KB |
#include <bits/stdc++.h> using namespace std; /* John Watson https://codeforces.com/profile/quangminh98 Mua Code nhu mua Florentino !! */ #define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long const int maxn = 2e5 + 9; const ll oo = 1e18; int n; int a[maxn]; int b[maxn]; ll pre[maxn], suff[maxn]; signed main() { if (fopen("test.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } faster(); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; b[i] = a[i] - a[i - 1]; } for (int i = 1; i <= n; i++) { pre[i] = pre[i - 1] + max(0, 1 - b[i]); suff[n - i + 1] = suff[n - i + 2] + max(0, 1 + b[n - i + 1]); } ll res = 1e18; for (int i = 1; i <= n; i++) res = min(res, max(pre[i], suff[i + 1])); cout << res << '\n'; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 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 | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 472 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 508 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 504 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 604 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 476 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 504 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 | 1 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 | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 472 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 508 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 504 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 604 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 476 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 504 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 17 ms | 7080 KB | Output is correct |
27 | Correct | 18 ms | 6864 KB | Output is correct |
28 | Correct | 18 ms | 7004 KB | Output is correct |
29 | Correct | 16 ms | 6948 KB | Output is correct |
30 | Correct | 13 ms | 6236 KB | Output is correct |
31 | Correct | 23 ms | 7032 KB | Output is correct |
32 | Correct | 18 ms | 7004 KB | Output is correct |
33 | Correct | 18 ms | 6968 KB | Output is correct |
34 | Correct | 17 ms | 6956 KB | Output is correct |
35 | Correct | 12 ms | 6236 KB | Output is correct |
36 | Correct | 14 ms | 6176 KB | Output is correct |
37 | Correct | 14 ms | 6220 KB | Output is correct |
38 | Correct | 17 ms | 7004 KB | Output is correct |
39 | Correct | 18 ms | 6992 KB | Output is correct |
40 | Correct | 17 ms | 7000 KB | Output is correct |
41 | Correct | 16 ms | 6896 KB | Output is correct |
42 | Correct | 16 ms | 6744 KB | Output is correct |
43 | Correct | 18 ms | 6996 KB | Output is correct |
44 | Correct | 17 ms | 6956 KB | Output is correct |
45 | Correct | 19 ms | 7004 KB | Output is correct |
46 | Correct | 17 ms | 7004 KB | Output is correct |
47 | Correct | 16 ms | 7004 KB | Output is correct |
48 | Correct | 17 ms | 7004 KB | Output is correct |