ADOBE UNIVERSITY HACKATHON 2026 OA | 65LPA CTC
Anonymous User
249

Problem: Hall of Shifting Tiles

A linear corridor of n tiles, numbered 1 to n. Each tile i has two attributes: a direction s[i], either < (points left) or > (points right), and a hardness cost c[i], a nonnegative integer time penalty.

An orb placed on a tile moves according to these rules, applied repeatedly:

Let the orb be on tile i. It immediately accumulates time equal to c[i].

Tile i flips its direction (< becomes > and vice versa).

The orb then moves one tile in the direction that tile i had before it was flipped — the original arrow seen on arrival.

This repeats until the orb leaves the corridor, landing at position 0 or n+1, at which point it escapes.

Answer n independent queries: for every starting position i where 1 ≤ i ≤ n, if the orb is placed on tile i in the original configuration, compute the total time — the sum of hardness costs of visited tiles — until the orb escapes. The corridor resets to its initial directions before each query.

Input

Line 1: integer n, the number of tiles.

Line 2: string s of length n, consisting only of < and >, giving each tile's initial arrow direction.

Line 3: n space-separated integers c₁ c₂ … cₙ, the hardness cost of each tile.

Comments (1)