Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,y) RFOR(i, y, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  vll t(N+2, 0), v(N+2, 0);
  t[0] = 0; v[0] = 0;
  REP(i, N) cin >> t[i+1];
  REP(i, N) cin >> v[i+1];
  t[N+1] = 0; v[N+1] = 0;

  ll t_sum=0;
  REP(i, N+2) t_sum += t[i];

  vector<double> v_min(2*t_sum+1, 100000.0);

  ll t_now=0;
  v_min[0] = 0.0;
  v_min[2*t_sum] = 0.0;
  REP(i, N+1){
    REP(j, 2*t[i]){
      v_min[t_now] = min((double)v[i], v_min[t_now]);
      t_now++;
    }
    v_min[t_now] = min((double)v[i], v_min[t_now]);
  }
  vector<double> v_limit_backward(2*t_sum+1, 0.0);
  double v_now=0;
  for(ll t_=2*t_sum-1; t_>=0; --t_){
    v_limit_backward[t_] = min(v_min[t_], v_now+0.5);
    //v_min[t_] = min(v_min[t_], v_min[t_+1]+0.5);
  }

  /*
  for(ll t_=1; t_<2*t_sum+1; ++t_){
    v_min[t_] = min(v_min[t_], v_min[t_-1]+0.5);
  }

  double ans=0.0;
  for(ll t_=0; t_<2*t_sum; ++t_){
    ans += (v_min[t_] + v_min[t_+1])/4.0;
  }
  */

  v_now = 0;
  for(ll t_=0; t_<2*t_sum; ++t_){
    double v_tmp = v_now;
    v_now = min(v_limit_backward[t_+1], v_now+0.5);
    ans += (v_now+v_tmp)/4.0;
    //cout << t_+1 << " " << v_now << " " << v_limit_backward[t_+1] << " " << ans <<  "\n";
  }

  printf("%.10lf\n", ans);
 
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:139:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
  139 |     ans += (v_now+v_tmp)/4.0;
      |     ^~~
      |     abs
a.cc:143:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
  143 |   printf("%.10lf\n", ans);
      |                      ^~~
      |                      abs