제출 #311601

#제출 시각아이디문제언어결과실행 시간메모리
311601biggBuilding Bridges (CEOI17_building)C++14
30 / 100
3070 ms3840 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;
const ll INF = 1e18;
ll h[MAXN], w[MAXN], dp[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]), dp[i] = INF;

	dp[1] = 0;
	for(int i = 2; i <= n; i++){
		ll s = 0;
		for(int j = i - 1; j >= 1; j--){
			dp[i] = min(dp[i], dp[j] + s  + (h[i]-h[j])*(h[i]-h[j]));
			s += w[j];
		}
	}
	printf("%lld\n",dp[n] );

}

컴파일 시 표준 에러 (stderr) 메시지

building.cpp: In function 'int main()':
building.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
building.cpp:10:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  for(int i = 1; i <= n; i++) scanf("%lld", &h[i]);
      |                              ~~~~~^~~~~~~~~~~~~~~
building.cpp:11:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |  for(int i = 1; i <= n; i++) scanf("%lld", &w[i]), dp[i] = INF;
      |                              ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...