Submission #311601

# Submission time Handle Problem Language Result Execution time Memory
311601 2020-10-10T18:29:18 Z bigg Building Bridges (CEOI17_building) C++14
30 / 100
3000 ms 3840 KB
#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] );

}

Compilation message

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 time Memory 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 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3070 ms 3840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Execution timed out 3070 ms 3840 KB Time limit exceeded
7 Halted 0 ms 0 KB -