I was just doing virtual on [problem:1338A].↵
↵
I wrote the following code:↵
<spoiler summary="#include <bits/stdc++.h>↵
using namespace std;↵
↵
typedef long long ll;↵
↵
typedef pair<int, int> pii;↵
typedef pair<ll, int> pli;↵
typedef pair<int, ll> pil;↵
typedef pair<ll, ll> pll;↵
↵
#define mp make_pair↵
#define fr first↵
#define sc second↵
↵
void solve() {↵
int N;↵
cin >> N;↵
vector<int> A(N);↵
for (int i = 0; i < N; i++) {↵
cin >> A[i];↵
}↵
if (is_sorted(A.begin(), A.end())) {↵
cout << 0 << '\n';↵
return;↵
}↵
int ans = 0, mx = -1e9;↵
for (int i = 0; i < N; i++) {↵
mx = max(mx, A[i]);↵
ans = max(ans, __lg(mx — A[i]) + 1);↵
}↵
cout << ans << '\n';↵
}↵
↵
int main() {↵
ios_base::sync_with_stdio(0);↵
cin.tie(0);↵
cout.tie(0);↵
#ifndef ONLINE_JUDGE↵
freopen("input.txt", "r", stdin);↵
freopen("output.txt", "w", stdout);↵
#endif↵
↵
int t = 1;↵
cin >> t;↵
while (t--) solve();↵
↵
return 0;↵
}">↵
...↵
↵
</spoiler>↵
↵
and it out puts "63" on this test.↵
</spoiler>↵
↵
...↵
</spoiler>[submission:121160133]↵
↵
and it out puts "63" on this test: N = 5, A = {-9, -2, -2, 7, 5}↵
↵
But I thought __lg(0) is -1?↵
↵
Does anyone have any idea?↵
↵
(Also I tried to use custom invocation and try to exit once "ans" is changed to 63 but nothing happened.)
↵
I wrote the following code:↵
using namespace std;↵
↵
typedef long long ll;↵
↵
typedef pair<int, int> pii;↵
typedef pair<ll, int> pli;↵
typedef pair<int, ll> pil;↵
typedef pair<ll, ll> pll;↵
↵
#define mp make_pair↵
#define fr first↵
#define sc second↵
↵
void solve() {↵
int N;↵
cin >> N;↵
vector<int> A(N);↵
for (int i = 0; i < N; i++) {↵
cin >> A[i];↵
}↵
if (is_sorted(A.begin(), A.end())) {↵
cout << 0 << '\n';↵
return;↵
}↵
int ans = 0, mx = -1e9;↵
for (int i = 0; i < N; i++) {↵
mx = max(mx, A[i]);↵
ans = max(ans, __lg(mx — A[i]) + 1);↵
}↵
cout << ans << '\n';↵
}↵
↵
int main() {↵
ios_base::sync_with_stdio(0);↵
cin.tie(0);↵
cout.tie(0);↵
#ifndef ONLINE_JUDGE↵
freopen("input.txt", "r", stdin);↵
freopen("output.txt", "w", stdout);↵
#endif↵
↵
int t = 1;↵
cin >> t;↵
while (t--) solve();↵
↵
return 0;↵
}">↵
...↵
↵
</spoiler>↵
↵
and it out puts "63" on this test.↵
</spoiler>↵
↵
...↵
</spoiler>
↵
and it out puts "63" on this test: N = 5, A = {-9, -2, -2, 7, 5}↵
↵
But I thought __lg(0) is -1?↵
↵
Does anyone have any idea?↵
↵
(Also I tried to use custom invocation and try to exit once "ans" is changed to 63 but nothing happened.)