Bus of Characters

TimeLimit:2000MS  MemoryLimit:256MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

In the Bus of Characters there are n rows of seat, each having  seats. The width of both seats in the i-th row is wi centimeters. All integers wi are distinct.

Initially the bus is empty. On each of  stops one passenger enters the bus. There are two types of passengers:

  • an introvert always chooses a row where both seats are empty. Among these rows he chooses the one with the smallest seats width and takes one of the seats in it;

  • an extrovert always chooses a row where exactly one seat is occupied (by an introvert). Among these rows he chooses the one with the largest seats width and takes the vacant place in it.

You are given the seats width in each row and the order the passengers enter the bus. Determine which row each passenger will take.


Input

The first line contains a single integer n (   ) — the number of rows in the bus.

The second line contains the sequence of integers w1,w2,,wn (), where wi is the width of each of the seats in the i-th row. It is guaranteed that all wi are distinct.

The third line contains a string of length 2n, consisting of digits '0' and '1' — the description of the order the passengers enter the bus. If the -th character is '0', then the passenger that enters the bus on the -th stop is an introvert. If the j-th character is '1', the the passenger that enters the bus on the -th stop is an extrovert. It is guaranteed that the number of extroverts equals the number of introverts (i. e. both numbers equal n), and for each extrovert there always is a suitable row.

Output

Print  integers — the rows the passengers will take. The order of passengers should be the same as in input.

SampleInput 1
2
3 1
0011
SampleOutput 1
2 1 1 2 
SampleInput 2
6
10 8 9 11 13 5
010010011101
SampleOutput 2
6 6 2 3 3 1 4 4 1 2 5 5 
Note

In the first example the first passenger (introvert) chooses the row 2, because it has the seats with smallest width. The second passenger (introvert) chooses the row 1, because it is the only empty row now. The third passenger (extrovert) chooses the row 1, because it has exactly one occupied seat and the seat width is the largest among such rows. The fourth passenger (extrovert) chooses the row 2, because it is the only row with an empty place.

Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签
出处

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: