답안 #128025

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128025 2019-07-10T10:36:08 Z faustaadp Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 8440 KB
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,a[101010],p[101010],d[101010],w[101010],b[101010];
ll depe(ll aa)
{
	if(aa==n)return 0;
	if(!b[aa])
	{
		b[aa]=1;
		d[aa]=1e18;
		ll ii;
		for(ii=aa+1;ii<=n;ii++)
			d[aa]=min(d[aa],depe(ii)+p[ii-1]-p[aa]+(a[aa]-a[ii])*(a[aa]-a[ii]));
	}
	return d[aa];
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)cin>>w[i];
	for(i=1;i<=n;i++)p[i]=p[i-1]+w[i];
	cout<<depe(1)<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 4 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3022 ms 8440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 4 ms 580 KB Output is correct
6 Execution timed out 3022 ms 8440 KB Time limit exceeded
7 Halted 0 ms 0 KB -