Comments

Can anyone please help me understand the third paragraph of the editorial for 1820B. It contains a lot of mathematics, which isn't making sense to me. Anyone's help will be greatly appreciated(;´д`)ゞ

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

int T, N;
lli ar[100];

void solve(){
	cin >> N;
	for(int i = 0; i < N; ++i)
		cin >> ar[i];

	int oprn = 0;
	for(int i = N - 2; i >= 0; --i){
		while(ar[i] > 0 && ar[i] >= ar[i + 1]){
			ar[i]/= 2;
			oprn++;
		}
		if(i > 0 && ar[i] == 0){
			cout << - 1 << "\n";
			return;
		}
	}
	cout << oprn << "\n";
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> T;
	while(T--){
		solve();
	}
	return 0;
}

Getting wrong answer from this solution.1675B][CONTEST:1675 - Make It Increasing