답안 #61785

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61785 2018-07-26T17:09:19 Z IvanC Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 3600 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 1e5 + 10;
const ll INF = 1e18;

ll dp[MAXN],H[MAXN],W[MAXN],pref[MAXN];
int N;

int main(){

	scanf("%d",&N);
	for(int i = 1;i<=N;i++){
		scanf("%lld",&H[i]);
	}
	for(int i = 1;i<=N;i++){
		scanf("%lld",&W[i]);
		pref[i] = W[i] + pref[i-1];
	}

	dp[1] = 0;
	for(int i = 2;i<=N;i++){
		dp[i] = INF;
		for(int j = 1;j<i;j++){
			dp[i] = min(dp[i], dp[j] + (pref[i-1] - pref[j]) + H[i]*H[i] + H[j]*H[j] - 2*H[i]*H[j]  );
		}
	}

	cout << dp[N] << endl;

	return 0;
}

Compilation message

building.cpp: In function 'int main()':
building.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
  ~~~~~^~~~~~~~~
building.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&H[i]);
   ~~~~~^~~~~~~~~~~~~~
building.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&W[i]);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 4 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 4 ms 488 KB Output is correct
5 Correct 4 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3087 ms 3600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 4 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 4 ms 488 KB Output is correct
5 Correct 4 ms 604 KB Output is correct
6 Execution timed out 3087 ms 3600 KB Time limit exceeded
7 Halted 0 ms 0 KB -