QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100 الصعوبة: [عرض] قابلة للهجوم ✓

#6366. 消息

الإحصائيات

一天晚上,Zenyk 决定给 Marichka 发一条温馨的信息,祝贺她春天到来。起初,他在手机上输入了信息 $s$,但过了一会儿,他意识到输入信息 $t$ 会更好。

不幸的是,现在修改信息并不容易——Zenyk 唯一能做的操作是删除任意字母的第一次出现或最后一次出现。请注意,他可以执行任意次数此操作。此外,字母并不是瞬间被删除的。删除最初位于字符串 $s$ 中第 $i$ 个位置的字符需要 $w_i$ 秒。

请帮助 Zenyk 计算使用上述操作将信息 $s$ 转换为 $t$ 所需的最少秒数。如果无法做到,请输出一行 “You better start from scratch man...” (不含引号)。

输入格式

第一行包含字符串 $s$,第二行包含字符串 $t$ ($1 \le |s|, |t| \le 200000$)。字符串 $s$ 和 $t$ 仅由小写拉丁字母 a-z 组成。

第三行包含 $|s|$ 个空格分隔的整数 $w_i$,每个整数表示删除对应字符所需的秒数 ($1 \le w_i \le 10^9$)。

输出格式

如果 Zenyk 能够将 $s$ 转换为 $t$,请输出所需的最少秒数。否则,输出 “You better start from scratch man...” (不含引号)。

样例

样例输入 1

ababccb
abc
7 2 2 4 3 2 1

样例输出 1

7

样例输入 2

babab
baab
2 1 3 2 4

样例输出 2

You better start from scratch man...

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.