이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define Pii pair< pii , pii >
#define int long long
using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 4e5 + 10 , maxq = 1e7 + 1 , inf = 1e8 + 10 , mod= 998244353 ,lg = 20 ;
int dp[maxn] , h[maxn] , w[maxn];
signed main(){
ios::sync_with_stdio(false); cin.tie(0) ;
int n ;
cin >> n;
for(int i =1 ; i<= n ;i++){
cin >> h[i] ;
}
int ans= 0 ;
for(int i = 1; i <= n ; i++){
cin >> w[i] ;
}
for(int i = 2; i <= n ; i++){
int sm =0 ;
dp[i] = inf ;
for(int j = i-1 ; j >= 1; j--){
dp[i] = min(sm + (h[i] - h[j]) * (h[i] - h[j]) + dp[j], dp[i]) ;
sm += w[j] ;
}
}
cout << dp[n] ;
}
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
building.cpp: In function 'int main()':
building.cpp:24:7: warning: unused variable 'ans' [-Wunused-variable]
24 | int ans= 0 ;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |