I was just doing virtual on [problem:1338A].↵
↵
I wrote the following code:↵
[submission:121160133]↵
↵
and it out puts "63" on this test: N = 5, A = {-9, -2, -2, 7, 5} on both versions of C++17.↵
↵
But I thought __lg(0) is -1?↵
↵
Does anyone have any idea?↵
↵
(Also I tried to use custom invocation and attempted to exit once "ans" is changed to 63 but nothing happened.)The probably problematic part is here:↵
↵
<spoiler summary="code">↵
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);↵
if(ans == 63){↵
cout<<"ERROR\n";↵
assert(false);↵
}↵
}↵
cout << ans << '\n';↵
</spoiler>↵
↵
But I thought __lg(0) is -1? Also in custom invocation, the error message never appears.↵
↵
Does anyone have any idea?
↵
I wrote the following code:↵
[submission:121160133]↵
↵
and it out puts "63" on this test: N = 5, A = {-9, -2, -2, 7, 5} on both versions of C++17.↵
↵
↵
Does anyone have any idea?↵
↵
(Also I tried to use custom invocation and attempted to exit once "ans" is changed to 63 but nothing happened.)
↵
<spoiler summary="code">↵
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);↵
if(ans == 63){↵
cout<<"ERROR\n";↵
assert(false);↵
}↵
}↵
cout << ans << '\n';↵
</spoiler>↵
↵
But I thought __lg(0) is -1? Also in custom invocation, the error message never appears.↵
↵
Does anyone have any idea?