#include #define debug(x) cerr << #x << ": " << x << endl #define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << endl using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector vll; const ll INF = LLONG_MAX/2; const ll MOD = 1e9+7; const double EPS=1e-12; template class ConvexHullTrick { private: vector> lines; int head; bool check(pair l1, pair l2, pair l3) { return (l3.second - l2.second) * (l2.first - l1.first) >= (l2.second - l1.second) * (l3.first - l2.first); } T f(int i, T x) { return lines[i].first * x + lines[i].second; } public: ConvexHullTrick():head(0){} bool empty(){ return lines.size()-head==0; } void insert(T a, T b) { pair line(a, b); if(lines.size()-head>=1&&a==lines.back().first&&b>lines.back().second)return; while (lines.size()-head >= 2 && check(*(lines.end() - 2), lines.back(), line)) lines.pop_back(); lines.emplace_back(line); } T getmin(T x) { while (lines.size() - head >= 2 && (f(head, x)>=f(head + 1, x))) ++head; return f(head, x); } }; signed main(){ cin.tie(0); ios::sync_with_stdio(false); ll N;cin>>N; ll a[N]; for(ll i=0;i>a[i]; ll x[N]; for(ll i=0;i>x[i]; ll y[N]; for(ll i=0;i>y[i]; ConvexHullTrick cht; ll dp=0; for(ll i=0;i