#B3826. Total Listening Time

    ID: 11483 Type: Default 1000ms 256MiB

Total Listening Time

Total Listening Time

Little Ran loves listening to music, but she suffers from indecisiveness so she relies on the player’s random play feature. The player will play n songs one after another. The length of the i-th song is \(a_i\) seconds, where \(100 \leq a_i \leq 320\).

However, not every song is to her liking. If she does not like a song, she will only listen to it for 10 seconds before switching to the next song (the switching time is negligible). Of course, if she likes the song, she will listen to the entire song.

You are given the list of songs along with whether Ran likes each song or not. Please calculate the total time in seconds that Ran will spend listening to these songs.

inputFormat

The input consists of three lines:

  1. An integer n (1 \(\leq n \leq 10^5\)) representing the number of songs.
  2. n space-separated integers \(a_1, a_2, \ldots, a_n\) where each \(a_i\) (100 \(\leq a_i \leq 320\)) is the length of the i-th song in seconds.
  3. n space-separated integers \(f_1, f_2, \ldots, f_n\), where each \(f_i\) is either 1 or 0. A value of 1 indicates that Ran likes the song, and 0 indicates that she does not.

outputFormat

Output a single integer representing the total time in seconds that Ran spends listening to the songs.

sample

3
150 120 200
1 0 1
360