From c52b36c6a37fdb1d1de146d3939cb42e2c691f44 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Sat, 5 Nov 2022 01:28:02 +0200 Subject: Solved 6 problem in filtrationContest and restructured the repo --- codeforces/MakeItIncreasing/MakeItIncreasing.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 codeforces/MakeItIncreasing/MakeItIncreasing.cpp (limited to 'codeforces/MakeItIncreasing') diff --git a/codeforces/MakeItIncreasing/MakeItIncreasing.cpp b/codeforces/MakeItIncreasing/MakeItIncreasing.cpp new file mode 100644 index 0000000..987ef04 --- /dev/null +++ b/codeforces/MakeItIncreasing/MakeItIncreasing.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; +int main() { + int tt; + cin >> tt; + while(tt--) { + int n; + int ans = 0; + cin >> n; + vector v(n); + for(auto &x : v) cin >> x; + for(int i = n - 1; i > 0; i--) { + while(v[i] <= v[i-1] && v[i - 1] > 0) { + v[i-1] = v[i-1] / 2; + ans++; + } + if(v[i] == v[i-1]) { + ans = -1; + break; + } + } + cout << ans << endl; + } +} -- cgit v1.2.3