#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long long
#define maxn 100050
struct Line {
ld m, b;
ld operator()(ld x) { return m * x + b; }
} a[maxn * 4];
void insert(int l, int r, Line seg, int o) {
if(l + 1 == r) {
if(seg(l) > a[o](l)) a[o] = seg;
return;
}
int mid= (l + r) >> 1, lson = o * 2 + 1, rson = o * 2 + 2;
if(a[o].m > seg.m) swap(a[o], seg);
if(a[o](mid) < seg(mid)) {
swap(a[o], seg);
insert(l, mid, seg, lson);
}
else insert(mid, r, seg, rson);
}
ld query(int l, int r, int x, int o) {
if(l + 1 == r) return a[o](x);
int mid = (l + r) >> 1, lson = o * 2 + 1, rson = o * 2 + 2;
if(x < mid) return max(a[o](x), query(l, mid, x, lson));
else return max(a[o](x), query(mid, r, x, rson));
}
int32_t main(){
ios::sync_with_stdio(0);
cin.ti
int n;
for(int i=0;i<4*maxn;i++){
a[i] = {-0,-LLONG_MAX};
}
cin >> n;
int input;
vector<int> vect1,vect2;
for(int i=0;i<n;i++){
cin >> input;
vect1.push_back(input);
}
for(int i=0;i<n;i++){
cin >> input;
vect2.push_back(input);
}
vect2[0] = 0;
for(int i=1;i<n;i++){
vect2[i] += vect2[i-1];
}
vector<int> dp(n,0);
insert(0,n,{2*vect1[0],-vect1[0]*vect1[0]},0);
for(int i=1;i<n;i++){
dp[i] = -query(0,n,vect1[i],0)+vect2[i-1]+vect1[i]*vect1[i];
insert(0,n,{2*vect1[i],-dp[i]+vect2[i]-vect1[i]*vect1[i]},0);
}
cout << dp[n-1];
}
Compilation message
building.cpp: In function 'int32_t main()':
building.cpp:32:7: error: 'std::istream {aka class std::basic_istream<char>}' has no member named 'ti'; did you mean 'tie'?
cin.ti
^~
tie
building.cpp:37:10: error: 'n' was not declared in this scope
cin >> n;
^