Language: C++

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll A[200001];
int log4p[200001],log4m[200001];
ll ruilog4p[200001]={},ruilog4m[200001]={};
ll ruiruilog4p[200002]={},ruiruilog4m[200002]={};
int main(){
	int N;
	ll ans=INFl;
	scan(N);
	rep(i,N){
		scan(A[i]);
	}
	rep(i,N-1){
		log4p[i]=max(0,(int)(ceil(log((double)A[i]/A[i+1])/log(4.0))+eps));
		ruilog4p[i+1]=ruilog4p[i]+log4p[i];
	}
	for(int i=N-2;i>=0;i--){
		log4m[i]=max(0,(int)(ceil(log((double)A[i+1]/A[i])/log(4.0))+eps));
		ruilog4m[i]=ruilog4m[i+1]+log4m[i];
	}
	rep(i,N){
		ruiruilog4p[i+1]=ruiruilog4p[i]+ruilog4p[i];
	}
	for(int i=N-1;i>=0;i--){
		ruiruilog4m[i]=ruiruilog4m[i+1]+ruilog4m[i];
	}
	/*rep(i,N){
		printf("i:%d ruip:%lld\n",i,ruilog4p[i]);
	}
	rep(i,N+1){
		printf("i:%d ruiruip:%lld\n",i,ruiruilog4p[i]);
	}
	rep(i,N){
		printf("i:%d ruim:%lld\n",i,ruilog4m[i]);
	}
	rep(i,N+1){
		printf("i:%d ruiruim:%lld\n",i,ruiruilog4m[i]);
	}*/
	rep(k,N+1){
		ll kans=k;
		ll kp=0,km=0;
		if(k<N-1) kp=max(0,(ruiruilog4p[N]-ruiruilog4p[k+1]-ruilog4p[k]*max(0,(N-k-1)))*2);
		if(k>1) km=max(0,(ruiruilog4m[0]-ruiruilog4m[k-1]-ruilog4m[k-1]*max(0,k-1))*2);
		kans+=kp+km;
		//printf("k:%d kp:%lld km:%lld kans:%lld\n",k,kp,km,kans);
		ans=min(ans,kans);
	}
	prin(ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:33: error: no matching function for call to 'max(int, ll)'
   71 |                 if(k<N-1) kp=max(0,(ruiruilog4p[N]-ruiruilog4p[k+1]-ruilog4p[k]*max(0,(N-k-1)))*2);
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:2:
/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:71:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   71 |                 if(k<N-1) kp=max(0,(ruiruilog4p[N]-ruiruilog4p[k+1]-ruilog4p[k]*max(0,(N-k-1)))*2);
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:3:
/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:71:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   71 |                 if(k<N-1) kp=max(0,(ruiruilog4p[N]-ruiruilog4p[k+1]-ruilog4p[k]*max(0,(N-k-1)))*2);
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:72:31: error: no matching function for call to 'max(int, ll)'
   72 |                 if(k>1) km=max(0,(ruiruilog4m[0]-ruiruilog4m[k-1]-ruilog4m[k-1]*max(0,k-1))*2);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:72:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   72 |                 if(k>1) km=max(0,(ruiruilog4m[0]-ruiruilog4m[k-1]-ruilog4m[k-1]*max(0,k-1))*2);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
/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:72:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   72 |                 if(k>1) km=max(0,(ruiruilog4m[0]-ruiruilog4m[k-1]-ruilog4m[k-1]*max(0,k-1))*2);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~