Module Module1 Sub Main() FileOpen(1, "DATA4.txt", OpenMode.Input) FileOpen(2, "OUT4.txt", OpenMode.Output) For i As Integer = 0 To 4 Dim space As Integer = CInt(LineInput(1)) Dim size = CInt(LineInput(1)) Dim songs() As String Dim albums(size - 1, 1) As Integer For b As Integer = 0 To size - 1 songs = Split(LineInput(1), " ", -1) albums(b, 0) = CInt(songs(0)) albums(b, 1) = CInt(songs(1)) Next Dim uti As Integer = 0 Dim utif As Integer = 0 For bb As Integer = 0 To size - 1 Dim spacel As Integer = space If albums(bb, 0) <= space Then uti = albums(bb, 1) spacel = space - albums(bb, 0) For bbb As Integer = bb To size - 1 If albums(bbb, 0) <= spacel Then uti = albums(bbb, 1) + uti spacel = spacel - albums(bbb, 0) For bbbb As Integer = bbb To size - 1 If albums(bbbb, 0) <= spacel Then uti = albums(bbbb, 1) + uti spacel = spacel - albums(bbbb, 0) For bbbbb As Integer = bbbb To size - 1 If albums(bbbbb, 0) <= spacel Then uti = albums(bbbbb, 1) + uti spacel = spacel - albums(bbbbb, 0) For bbbbbb As Integer = bbbbb To size - 1 If albums(bbbbbb, 0) <= spacel Then uti = albums(bbbbbb, 1) + uti spacel = spacel - albums(bbbbbb, 0) For bbbbbbb As Integer = bbbbbb To size - 1 If albums(bbbbbbb, 0) <= spacel Then uti = albums(bbbbbbb, 1) + uti spacel = spacel - albums(bbbbbbb, 0) For bbbbbbbb As Integer = bbbbbbb To size - 1 If albums(bbbbbbbb, 0) <= spacel Then uti = albums(bbbbbbbb, 1) + uti spacel = spacel - albums(bbbbbbbb, 0) End If Next End If Next End If Next End If Next End If Next End If Next If uti > utif Then utif = uti End If End If Next Dim out As String = CStr(utif) PrintLine(2, out) If i <> 4 Then LineInput(1) End If Next End Sub End Module