답안 #309852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309852 2020-10-04T17:29:44 Z peuch Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 3404 KB
#include<bits/stdc++.h>
using namespace std;

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

int n;
long long h[MAXN], sw[MAXN];
long long dp[MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &h[i]);
	for(int i = 1; i <= n; i++){
		int aux;
		scanf("%d", &aux);
		sw[i] = sw[i - 1] + aux;
	}
	for(int i = 2; i <= n; i++){
		dp[i] = INF;
		for(int j = 1; j < i; j++)
			dp[i] = min(dp[i], dp[j] + (h[i] - h[j]) * (h[i] - h[j]) + sw[i - 1] - sw[j]);
	}
	printf("%d\n", dp[n]);
}
/*
6
3 8 7 1 6 6
0 -1 9 1 2 0
*/

Compilation message

building.cpp: In function 'int main()':
building.cpp:14:11: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   14 |   scanf("%d", &h[i]);
      |          ~^   ~~~~~
      |           |   |
      |           |   long long int*
      |           int*
      |          %lld
building.cpp:25:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   25 |  printf("%d\n", dp[n]);
      |          ~^     ~~~~~
      |           |         |
      |           int       long long int
      |          %lld
building.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
building.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   scanf("%d", &h[i]);
      |   ~~~~~^~~~~~~~~~~~~
building.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |   scanf("%d", &aux);
      |   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3079 ms 3404 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Execution timed out 3079 ms 3404 KB Time limit exceeded
7 Halted 0 ms 0 KB -