diff --git a/Codes/1981 C - Turtle and an Incomplete Sequence/1981C.cpp b/Codes/1981 C - Turtle and an Incomplete Sequence/1981C.cpp new file mode 100644 index 0000000..6b0e64b --- /dev/null +++ b/Codes/1981 C - Turtle and an Incomplete Sequence/1981C.cpp @@ -0,0 +1,79 @@ +#include +using namespace std; +#define ll long long +#define endl '\n' +ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;} + +void solve() +{ + int n; + cin>>n; + vectorv(n); + for(auto &i:v) cin>>i; + int prev=-1; + for(int i=0; i=0; --j) + { + if(v[j+1]>1) v[j]=v[j+1]/2; + else v[j]=v[j+1]*2; + } + prev=i; + continue; + } + int l=prev, r=i; + while(r-l>1) + { + if(v[r]>v[l]) + { + v[r-1]=v[r]/2; + r--; + } + else + { + if(v[l]>1) v[l+1]=v[l]/2; + else v[l+1]=v[l]*2; + l++; + } + } + prev=i; + } + if(prev1) v[i]=v[i-1]/2; + else v[i]=v[i-1]*2; + } + } + for(int i=0; i> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "<