Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vs64 a(n); rep (i, n) cin >> a[i];

    s64 ans = 0;
    s64 p = 0;
    rep (i, n)
    {
        // cout << "p = " << p << "\n";
        if (a[i] <= p + 1)
        {
            p = a[i];
            // cout << a[i] << " -> " << a[i] << "\n";
            // cout << "ans += 0\n";
        }
        else
        {
            ans += (a[i] - 1) / (p + 1);
            // cout << a[i] << " -> " << 1 << "\n";
            // cout << "ans += " << (a[i] - 1) / (p + 1) << "\n";
            p = max(p, 1ll);
            // a[i] = 1;
        }
        // rep (j, n) cout << a[j] << " ";
        // cout << "\n";
    }

    cout << ans << "\n";
    return 0;
}



Compiler output:
a.cc:20:9: error: 'uint64_t' does not name a type
   20 | typedef uint64_t u64;
      |         ^~~~~~~~
a.cc:17:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   16 | #include <numeric>
  +++ |+#include <cstdint>
   17 | 
a.cc:22:9: error: 'uint32_t' does not name a type
   22 | typedef uint32_t u32;
      |         ^~~~~~~~
a.cc:22:9: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:25:16: error: 'u32' was not declared in this scope; did you mean 's32'?
   25 | typedef vector<u32> vu32;
      |                ^~~
      |                s32
a.cc:25:19: error: template argument 1 is invalid
   25 | typedef vector<u32> vu32;
      |                   ^
a.cc:25:19: error: template argument 2 is invalid
a.cc:27:16: error: 'u64' was not declared in this scope; did you mean 's64'?
   27 | typedef vector<u64> vu64;
      |                ^~~
      |                s64
a.cc:27:19: error: template argument 1 is invalid
   27 | typedef vector<u64> vu64;
      |                   ^
a.cc:27:19: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:67:20: error: no matching function for call to 'max(s64&, long long int)'
   67 |             p = max(p, 1ll);
      |                 ~~~^~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:67:20: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   67 |             p = max(p, 1ll);
      |                 ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:67:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   67 |             p = max(p, 1ll);
      |                 ~~~^~~~~~~~