# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
963214 |
2024-04-14T18:22:12 Z |
biank |
Skyline (IZhO11_skyline) |
C++14 |
|
1252 ms |
262144 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300;
using ll = long long;
const ll INF = 1e18;
ll dp[MAX_N][MAX_N][MAX_N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
vector<int> h(n + 2);
for (int i = 2; i <= n + 1; i++) {
cin >> h[i];
}
for (int i = 2; i <= n + 1; i++) {
for (int j = 0; j <= h[i - 1]; j++) {
for (int k = 0; k <= h[i]; k++) {
dp[i][j][k] = INF;
if (k != 0) dp[i][j][k] = min(dp[i][j][k], dp[i][j][k - 1] + 3LL);
if (j != 0 && k != 0) dp[i][j][k] = min(dp[i][j][k], dp[i][j - 1][k - 1] + 5LL);
if (j >= k && h[i - 2] >= k) dp[i][j][k] = min(dp[i][j][k], dp[i - 1][h[i - 2] - k][j - k] + 7LL * k);
}
}
}
cout << dp[n + 1][h[n]][h[n + 1]] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
13 ms |
51752 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
2 ms |
8540 KB |
Output is correct |
7 |
Correct |
1 ms |
8540 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
10588 KB |
Output is correct |
10 |
Correct |
3 ms |
18776 KB |
Output is correct |
11 |
Correct |
21 ms |
78684 KB |
Output is correct |
12 |
Correct |
6 ms |
22876 KB |
Output is correct |
13 |
Correct |
20 ms |
87872 KB |
Output is correct |
14 |
Correct |
28 ms |
95972 KB |
Output is correct |
15 |
Correct |
73 ms |
142932 KB |
Output is correct |
16 |
Correct |
70 ms |
132668 KB |
Output is correct |
17 |
Runtime error |
1252 ms |
262144 KB |
Execution killed with signal 9 |
18 |
Halted |
0 ms |
0 KB |
- |