# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
959319 | gmroh06 | 빌딩 장식 3 (JOI15_building3) | C++14 | 79 ms | 14928 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#import <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
inline void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
ll n, ans = 1, cnt, loc;
vector<ll> arr;
int main() {
fastio();
cin >> n;
arr.resize(n);
for (ll i = 1; i < n; i++) {
cin >> arr[i];
}
for (ll i = 0, h = 0; i < n; i++) {
if (arr[i] - h > 2) {
cout << 0 << '\n';
return 0;
} else if (arr[i] - h == 2) {
if (cnt) {
cout << 0 << '\n';
return 0;
} else {
cnt = arr[i];
loc = i;
}
}
h = max(h, arr[i]);
ans += h;
}
if (cnt) {
for (ll i = 0; i < loc; i++) {
if (arr[i] + 2 == cnt) {
ans = loc - i;
break;
}
}
}
cout << ans << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |