| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1319920 | segfaulted | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++20 | 0 ms | 332 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
class Solve {
public:
void solve() {
int n;
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++) cin >> a[i];
vector<int> l(n);
l[0] = a[0];
for(int i = 1; i < n; i++) l[i] = max(a[i], l[i-1]+1);
vector<int> r(n);
r[n-1] = a[n-1];
for(int i = n-2; i >= 0; i--) r[i] = max(a[i], r[i+1]+1);
ll ans = 0;
for(int i = 0; i < n; i++) ans += max(l[i], r[i]) - a[i];
cout << ans << endl;
}
};
signed main(signed argc, char* argv[]) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
if (argc > 1 && string(argv[1]) == "allyst") {
freopen("in.case", "r", stdin);
freopen("out.case", "w", stdout);
}
Solve T;
T.solve();
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
