Codeforces Round 633 (Div. 2) 1339C - Powered Addition / Codeforces Round 633 (Div. 1) 1338A. Powered Addition Solution
Problem Link : https://codeforces.com/contest/1338/problem/A , https://codeforces.com/contest/1339/problem/C
Solution in C++:
- /// La ilaha illellahu muhammadur rasulullah
- ///******Bismillahir-Rahmanir-Rahim******///
- /// Abul Hasnat Tonmoy
- /// Department of CSE,23rd batch
- /// Islamic University,Bangladesh
- ///**********ALLAH IS ALMIGHTY************///
- #include <bits/stdc++.h>
- using namespace std;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t ;
- cin >> t ;
- while ( t-- ) {
- int n ;
- cin >> n ;
- int a[n+1] ;
- for ( int i = 0 ; i < n ; i++ ){
- cin >> a[i] ;
- }
- int mx = 0 ;
- for ( int i = 1 ; i < n ; i++ ) {
- if ( a[i - 1] > a[i] ) {
- mx = max ( mx , a[i - 1] - a[i] ) ;
- a[i] = a[i - 1] ;
- }
- }
- cout << (int )ceil(log2(mx+1)) << endl;
- }
- return 0 ;
- }
No comments