# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47232 | robert | Building Bridges (CEOI17_building) | C++14 | 82 ms | 6776 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
int N;
int h[100100], w[100100];
int m[1001][1000];
int solve(int n, int ln){
if(n==0){
///first node
return solve(n+1, n);
}
else if(n==N-1){
//last node
return abs(h[n]-h[ln])*abs(h[n]-h[ln]);
}
if(m[n][ln]!=-1)
return m[n][ln];
return m[n][ln] = min(solve(n+1, n)+(abs(h[n]-h[ln])*abs(h[n]-h[ln])), solve(n+1, ln)+w[n]);
}
int main(){
cin>>N;
memset(m, -1, sizeof(m));
for(int n=0; n<N; n++){
cin>>h[n];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |