Submission #89369

# Submission time Handle Problem Language Result Execution time Memory
89369 2018-12-12T11:30:21 Z semiauto Building Bridges (CEOI17_building) C++14
30 / 100
3000 ms 2780 KB
#include <bits/stdc++.h>
using namespace std;
int n,i,j;
long long x,s[100001],h[100001],dp[100001];
int main()
	{
	cin>>n;
	for (i=1;i<=n;i++)
		cin>>h[i];
	for (i=1;i<=n;i++)
		{
		cin>>x;
		s[i]=s[i-1]+x;
		dp[i]=100000000000000000;
		}
	dp[1]=0;
	for (i=2;i<=n;i++)
		for (j=1;j<i;j++)
			dp[i]=min(dp[i],dp[j]+s[i-1]-s[j]+h[i]*h[i]+h[j]*h[j]-2*h[i]*h[j]);
	cout<<dp[n]<<endl;
	}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 4 ms 584 KB Output is correct
5 Correct 4 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3010 ms 2780 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 4 ms 584 KB Output is correct
5 Correct 4 ms 604 KB Output is correct
6 Execution timed out 3010 ms 2780 KB Time limit exceeded
7 Halted 0 ms 0 KB -