Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

const int64_t inf = (1LL << 50);

int64_t dp[200010][15];

vector<int64_t> computeScore(const std::vector<int64_t>& a) {
    int n = a.size();
    for (int x = 0; x < 15; x++) {
        dp[n - 1][x] = 2 * x;
    }

    for (int i = n - 2; i >= 0; i--) {
        int64_t cur = a[i];

        for (int x = 0; x < 15; x++) {
            dp[i][x] = inf;

            int64_t nxt = a[i + 1];

            for (int y = 0; y < 15; y++) {
                // 4^x * a_i <= 4^y * a_{i+1}
                if (cur <= nxt) {
                    dp[i][x] = min(dp[i][x], dp[i + 1][y] + 2 * x);
                } else {
                    dp[i][x] = min(dp[i][x], dp[i + 1][y] + 2 * (x + 15 * (n - i - 1)));
                }
                nxt *= 4;
            }
            cur *= 4;
        }
    }

    vector<int64_t> score(n);
    for (int i = 0; i < n; i++) {
        score[i] = dp[i][0];
    }
    return score;
}

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

    int n;
    cin >> n;

    vector<int64_t> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    auto score1 = computeScore(a);

    reverse(a.begin(), a.end());

    auto score2 = computeScore(a);

    reverse(score2.begin(), score2.end());

    int64_t ans = (1LL << 50);

    for (int i = 0; i < n; i++) {
        ans = min(ans, i + score1[i] + (i > 0 ? score2[i - 1] : 0LL));
    }
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:18: error: no matching function for call to 'min(int64_t&, long long int)'
   67 |         ans = min(ans, i + score1[i] + (i > 0 ? score2[i - 1] : 0LL));
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: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:67:18: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   67 |         ans = min(ans, i + score1[i] + (i > 0 ? score2[i - 1] : 0LL));
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:3:
/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:67:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   67 |         ans = min(ans, i + score1[i] + (i > 0 ? score2[i - 1] : 0LL));
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~