Const maxn = 500005
Dim n As Long, a As Long, b As Long
Dim f(1 To maxn) As Long
Dim i As Long, tby As Long
Private Sub Command1_Click()
tby = 1
n = Val(Text1.Text) : a = Val(Text2.Text) : b = Val(Text3.Text)
For i = 1 To n
f(i) = Getin()
Next i
Dim l As Long, r As Long, m As Long
l = 0: r = n
Do While l <= r
m = (l + r) / 2
If Then
r = m - 1
Else
l = m + 1
End If
Loop
Label1.Caption = Str(r + 1)
End Sub
Function check(x As Long)
Dim y As Long
y = x
For i = 1 To n
Dim tmp As Long
If tmp > 0 Then
If y < 0 Then
check = True
Exit Function
End If
Next i
check = False
End Function
Function Getin() As Long
Dim aaa As String
aaa = Mid(Text4.Text, tby, 1)
If aaa = " " Then tby = tby + 1
aaa = Mid(Text4.Text, tby, 1)
Dim bbb As Long
bbb = 0
Do While aaa <> " " And tby <= Len(Text4.Text)
bbb = bbb * 10 + Val(aaa) : tby = tby + 1
aaa = Mid(Text4.Text, tby, 1)
Loop
Getin = bbb
End Function