# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1045710 |
2024-08-06T07:05:37 Z |
ezzzay |
Skyline (IZhO11_skyline) |
C++14 |
|
54 ms |
101212 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e5+5;
vector<int>ans;
int a[N];
int dp[305][205][205];
signed main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=0;i<305;i++){
for(int j=0;j<205;j++){
for(int k=0;k<205;k++){
dp[i][j][k]=1e9;
}
}
}
for(int i = 0;i<=a[1];i++)dp[2][a[1]-i][a[2]] = dp[1][0][a[1]-i] = i*3;
for(int i=2;i<=n;i++){
for(int j=a[i-1];j>=0;j--){
for(int k=a[i];k>=0;k--){
dp[i][j][k]=min(dp[i][j][k],dp[i][j][k+1]+3);
}
}
for(int j=a[i-1];j>=0;j--){
for(int k=a[i];k>=0;k--){
dp[i][j][k]=min(dp[i][j][k],dp[i][j+1][k+1]+5);
}
}
if(n==i)continue;
for(int j=min({a[i],a[i-1],a[i+1]});j>=0;j--){
for(int k=a[i];k>=j;k--){
dp[i+1][k-j][a[i+1]-j]=min(dp[i+1][k-j][a[i+1]-j],dp[i][j][k] + j*7);
}
}
}
cout<<dp[n][0][0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
100952 KB |
Output is correct |
2 |
Correct |
11 ms |
100956 KB |
Output is correct |
3 |
Correct |
11 ms |
100956 KB |
Output is correct |
4 |
Correct |
11 ms |
101016 KB |
Output is correct |
5 |
Correct |
12 ms |
101164 KB |
Output is correct |
6 |
Correct |
11 ms |
100956 KB |
Output is correct |
7 |
Correct |
11 ms |
101076 KB |
Output is correct |
8 |
Correct |
11 ms |
100996 KB |
Output is correct |
9 |
Correct |
11 ms |
100952 KB |
Output is correct |
10 |
Correct |
12 ms |
101008 KB |
Output is correct |
11 |
Correct |
16 ms |
101024 KB |
Output is correct |
12 |
Correct |
12 ms |
101212 KB |
Output is correct |
13 |
Correct |
18 ms |
101136 KB |
Output is correct |
14 |
Correct |
19 ms |
101128 KB |
Output is correct |
15 |
Correct |
36 ms |
100956 KB |
Output is correct |
16 |
Correct |
36 ms |
101152 KB |
Output is correct |
17 |
Correct |
54 ms |
100956 KB |
Output is correct |
18 |
Correct |
52 ms |
100956 KB |
Output is correct |
19 |
Correct |
49 ms |
101056 KB |
Output is correct |
20 |
Correct |
48 ms |
100952 KB |
Output is correct |