제출 #43231

#제출 시각아이디문제언어결과실행 시간메모리
43231krauchBuilding Bridges (CEOI17_building)C++14
0 / 100
3004 ms2772 KiB
/* _ _ _______ _ _ | | / / | _____| | | / / | | / / | | | | / / | |/ / | |_____ | |/ / | |\ \ | _____| | |\ \ | | \ \ | | | | \ \ | | \ \ | |_____ | | \ \ |_| \_\ |_______| |_| \_\ */ #include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef double ld; typedef pair <int, int> PII; typedef pair <ll, ll> PLL; typedef pair < ll, int > PLI; #define F first #define S second #define pb push_back #define eb emplace_back #define right(x) x << 1 | 1 #define left(x) x << 1 #define forn(x, a, b) for (int x = a; x <= b; ++x) #define for1(x, a, b) for (int x = a; x >= b; --x) #define mkp make_pair #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() #define y1 kekekek #define fname "" const ll ool = 1e18 + 9; const int oo = 1e9 + 9, base = 1e9 + 7; const ld eps = 1e-7; const int N = 2e6 + 6; int n; ll h[N], w[N], d[N]; int main() { ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0); #ifdef krauch freopen("input.txt", "r", stdin); #else //freopen(fname".in", "r", stdin); //freopen(fname".out", "w", stdout); #endif cin >> n; forn(i, 1, n) { cin >> h[i]; } ll sum = 0; forn(i, 1, n) { cin >> w[i]; sum += w[i]; } forn(i, 2, n) { d[i] = ool; forn(j, 1, i - 1) { d[i] = min(d[i], d[j] + (h[i] - h[j]) * (h[i] - h[j]) - w[i]); } } cout << d[n] + sum << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...