# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1109264 | Tsagana | Skyline (IZhO11_skyline) | C++14 | 2037 ms | 760 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.
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define lnl long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
using namespace std;
int antiloop = 0;
int mn = INT_MAX;
void calc(int l, int r, vector<int> v, int k) {
for (int i = l; i <= r; i++) v[i]--;
while (!v[l] && l < v.size()) l++;
if (l == v.size()) {mn = min(mn, k); return ;}
for (int i = l; i <= l + 2; i++) {
if (!v[i] || i == v.size()) break ;
if (i == l) calc(l, i, v, k + 3);
if (i == l+1) calc(l, i, v, k + 5);
if (i == l+2) calc(l, i, v, k + 7);
}
}
void solve () {
int n; cin >> n;
vector<int> v(n);
for (auto &i: v) cin >> i;
calc(0, -1, v, 0);
cout << mn;
}
int main() {IOS solve(); return 0;}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |