# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
682750 | Summers | Skyline (IZhO11_skyline) | C++14 | 127 ms | 95400 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 endl '\n'
using namespace std;
long long a[1000000], dp[301][201][201];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long i,j,p,n,m,t,mini;
cin>>n;
for(i=1;i<=n;i++)
{
cin>>a[i];
}
for(i=0;i<=n;i++)
{
for(j=0;j<=200;j++)
{
for(p=0;p<=200;p++)dp[i][p][j]=10000000000;
}
}
for(i=0;i<=a[1];i++)
dp[1][0][i]=3*i;
for(i=2;i<=n;i++)
{
for(j=0;j<=a[i-1];j++)
{
for(p=0;p<=a[i];p++)
{
if(p>0)dp[i][j][p]=dp[i][j][p-1]+3;
if(p>0 && j>0)dp[i][j][p]=min(dp[i][j][p], dp[i][j-1][p-1]+5);
int mini=min(j,p);
if(mini<=a[i-2])
{
dp[i][j][p]=min(dp[i][j][p], dp[i-1][a[i-2]-mini][j-mini]+7*mini+3*(p-mini));
}
}
}
}
cout<<dp[n][a[n-1]][a[n]]<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |