問題一覧 > 通常問題

No.3067 +10 Seconds Clock

レベル : / AI推定難易度 : 725 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 111
作問者 : 👑 AngrySadEight / テスター : friedrice 👑 hamamu
お気に入りにしたユーザー ProblemId : 11767 / 自分の提出
問題文最終更新日: 2025-03-20 11:09:43
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 461 (順位表) の他の問題:

Problem Statement

You are going to play a course in a certain game. This course has $N$ points, numbered $1, 2, \dots, N$; point $1$ is the start and point $N$ is the goal.

For each integer $1 \leq i \leq N - 1$, you can move from point $i$ to point $i + 1$. This takes $t_i$ seconds. No other way of moving is possible.

This course has a time limit. The remaining time is represented by a value called the count, whose value at the moment of starting is $T$. After that, it decreases by $1$ every time $1$ second passes, and the game is over when the value becomes $0$.

In addition, +10 Seconds Clocks are placed at $K$ points $x_1, x_2, \dots, x_K$. A +10 Seconds Clock can be obtained when you are at the point where it is placed and the value of the count is at least $1$. The moment you obtain it, the value of the count increases by $10$. If you reach a point with a +10 Seconds Clock at the very moment the value of the count becomes $0$, you cannot obtain the +10 Seconds Clock.

You want to obtain as few +10 Seconds Clocks as possible before reaching the goal.

Find the minimum number of +10 Seconds Clocks obtained before reaching the goal without the game being over. If you cannot reach the goal without the game being over, report that.

Note that the time taken to obtain a +10 Seconds Clock is ignored. Also, if the count becomes $0$ at the same moment you reach the goal, the game is also over, and you are considered not to have reached the goal.

Constraints

  • All inputs are integers
  • $3 \leq N \leq 2 \times 10^5$
  • $1 \leq T \leq 4 \times 10^6$
  • $1 \leq t_i \leq 20$
  • $1 \leq K \leq N - 2$
  • $2 \leq x_1 < x_2 < \dots < x_K \leq N - 1$

Input

The input is given from standard input in the following format.

$N$ $T$
$t_1$ $t_2$ $\cdots$ $t_{N-1}$
$K$
$x_1$ $x_2$ $\cdots$ $x_K$

Output

If you cannot reach the goal, output -1. If you can reach the goal, output the minimum number of +10 Seconds Clocks obtained.

Sample

Sample 1
Input
6 20
4 5 6 7 8
3
2 3 5
Output
2

By acting as follows, you can reach the goal after obtaining $2$ +10 Seconds Clocks.

  • Move from point $1$ to point $2$. The count becomes $20 - 4 = 16$.
  • Obtain the +10 Seconds Clock at point $2$, and move from point $2$ to point $3$. The count becomes $16 + 10 - 5 = 21$.
  • Without obtaining the +10 Seconds Clock at point $3$, move from point $3$ to point $4$. The count becomes $21 - 6 = 15$.
  • Move from point $4$ to point $5$. The count becomes $15 - 7 = 8$.
  • Obtain the +10 Seconds Clock at point $5$, and move from point $5$ to point $6$. The count becomes $8 + 10 - 8 = 10$.

It is impossible to reach the goal after obtaining $1$ or fewer +10 Seconds Clocks. Note that if you did not obtain the last +10 Seconds Clock in the example above, the count would become $0$ at the moment you reach point $6$, but this is not considered as having reached the goal.

Sample 2
Input
3 10
10 1
1
2
Output
-1

You cannot reach the goal. Note that if the value of the count is $0$ at the moment you reach a point with a +10 Seconds Clock, you cannot obtain the +10 Seconds Clock.

Sample 3
Input
5 4000000
20 20 20 20
3
2 3 4
Output
0

You can reach the goal without obtaining even $1$ +10 Seconds Clock.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。