Language: C++

#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

vector<double> t;
vector<double> v;
vector<double> t_sum;
double ans;

int main() {
    int N; cin >> N;
    t.assign(N,0);
    v.assign(N,0);
    t_sum.assign(N+1,0);
    REP(i,N) cin >> t[i];
    REP(i,N) cin >> v[i];

    REP(i,N) t_sum[i+1] += t_sum[i] + t[i];
    ans = 0.0;
    vector<vector<double>> g(N+2,vector<double>(3,0));
    REP(i,N){
        g[i][0] = v[i] + t_sum[i];
        g[i][1] = v[i];
        g[i][2] = v[i] - t_sum[i+1];
    }
    
    for(double x = 0.0; x<=t_sum[N]; x+=0.5){
        int itr = upper_bound(ALL(t_sum), x) - t_sum.begin()-1;
        long double num = INF;
        REP(i,N){
            if(i<itr){
                num = min(num, g[i][2]+x);
            }else if(i==itr){
                num = min(num, g[i][1]);
            }else{
                num = min(num, g[i][0]-x);
            }
            num = min(num, x);
            num = min(num, t_sum[N]-x);
        }
        ans += num;
    }
    cout << ans/2 << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:26: error: no matching function for call to 'min(long double&, __gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type)'
   38 |                 num = min(num, g[i][2]+x);
      |                       ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:38:26: note:   deduced conflicting types for parameter 'const _Tp' ('long double' and '__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type' {aka 'double'})
   38 |                 num = min(num, g[i][2]+x);
      |                       ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:38:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long double'
   38 |                 num = min(num, g[i][2]+x);
      |                       ~~~^~~~~~~~~~~~~~~~
a.cc:40:26: error: no matching function for call to 'min(long double&, __gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type&)'
   40 |                 num = min(num, g[i][1]);
      |                       ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:40:26: note:   deduced conflicting types for parameter 'const _Tp' ('long double' and '__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type' {aka 'double'})
   40 |                 num = min(num, g[i][1]);
      |                       ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:40:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long double'
   40 |                 num = min(num, g[i][1]);
      |                       ~~~^~~~~~~~~~~~~~
a.cc:42:26: error: no matching function for call to 'min(long double&, __gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type)'
   42 |                 num = min(num, g[i][0]-x);
      |                       ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:42:26: note:   deduced conflicting types for parameter 'const _Tp' ('long double' and '__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type' {aka 'double'})
   42 |                 num = min(num, g[i][0]-x);
      |                       ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:42:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long double'
   42 |                 num = min(num, g[i][0]-x);
      |                       ~~~^~~~~~~~~~~~~~~~
a.cc:44:22: error: no matching function for call to 'min(long double&, double&)'
   44 |             num = min(num, x);
      |                   ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:44:22: note:   deduced conflicting types for parameter 'const _Tp' ('long double' and 'double')
   44 |             num = min(num, x);
      |                   ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:44:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long double'
   44 |             num = min(num, x);
      |                   ~~~^~~~~~~~
a.cc:45:22: error: no matching function for call to 'min(long double&, __gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type)'
   45 |             num = min(num, t_sum[N]-x);
      |                   ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:45:22: note:   deduced conflicting types for parameter 'const _Tp' ('long double' and '__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type' {aka 'double'})
   45 |             num = min(num, t_sum[N]-x);
      |                   ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:45:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long double'
   45 |             num = min(num, t_sum[N]-x);
      |                   ~~~^~~~~~~~~~~~~~~~~