QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 64 MB Puntuación total: 20

#23795. Traveler

Estadísticas

Problem

The JOI Highway runs straight east and west, and there are $n$ post towns along the JOI Highway. The post towns are numbered $1, 2, \dots, n$ in order from west to east. Post town $1$ is the westernmost post town, and post town $n$ is the easternmost post town.

Mr. JOI departs from post town $1$ on an $m$-day journey. He decides his travel itinerary according to a sequence $a_1, a_2, \dots, a_m$. Here, $a_i$ is a non-zero integer representing the movement method on day $i$. Specifically, if Mr. JOI departs from post town $k$ on day $i$, he moves straight from post town $k$ to post town $k + a_i$ within day $i$.

Given the number of post towns $n$, the number of travel days $m$, the information about the distances between adjacent post towns, and the sequence $a_1, a_2, \dots, a_m$ representing the movement methods, write a program to find the remainder when Mr. JOI's total travel distance over the $m$-day journey is divided by $100000 = 10^5$.

Input

Read the input from the file input.txt.

On line $1$ of the input, two integers $n, m$ ($2 \le n \le 100000 = 10^5$, $1 \le m \le 100000 = 10^5$) separated by a space are written, representing the number of post towns $n$ and the number of travel days $m$.

On the following $n - 1$ lines, the distances between adjacent post towns are written. On line $i + 1$ ($1 \le i \le n - 1$), a positive integer $s_i$ ($1 \le s_i \le 100$) representing the distance between post town $i$ and post town $i + 1$ is written.

On the following $m$ lines, the information about the movement methods is written. On line $i + n$ ($1 \le i \le m$), a non-zero integer $a_i$ representing the movement method on day $i$ is written. There is never a movement going west of post town $1$ or going east of post town $n$.

In $50\%$ of the scoring data, $n \le 100$ and $m \le 100$ hold.

Output

Output to the file output.txt.

The output consists of $1$ line containing the remainder when Mr. JOI's total travel distance over the $m$-day journey is divided by $100000 = 10^5$.

Sample 1

Input

7 5
2
1
1
3
2
1
2
-1
3
2
-3

Output

18

Explanation

fig1

On day $1$, he moves from post town $1$ to post town $3$. On day $2$, he moves from post town $3$ to post town $2$. On day $3$, he moves from post town $2$ to post town $5$. On day $4$, he moves from post town $5$ to post town $7$. On day $5$, he moves from post town $7$ to post town $4$. The total travel distance over the $5$-day journey is $18$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.