A15653 | Algebra Flash
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Algebra Flash 2.2 has just been released!Changelog:
- New gamemode!
Thank you for the continued support of the game!
Huh, is that it? Slightly disappointed, you boot up the game and click on the new gamemode. It says "Colored platforms".
There are $n$ platforms, numbered from $1$ to $n$ , placed one after another. There are $m$ colors available in the game, numbered from $1$ to $m$ . The $i$ -th platform is colored $c_i$ .
You start on the platform $1$ and want to reach platform $n$ . In one move, you can jump from some platform $i$ to platforms $i + 1$ or $i + 2$ .
All platforms are initially deactivated (including platforms $1$ and $n$ ). For each color $j$ , you can pay $x_j$ coins to activate all platforms of that color.
You want to activate some platforms so that you could start on an activated platform $1$ , jump through some activated platforms and reach an activated platform $n$ .
What's the smallest amount of coins you can spend to achieve that?
- New gamemode!
Thank you for the continued support of the game!
Huh, is that it? Slightly disappointed, you boot up the game and click on the new gamemode. It says "Colored platforms".
There are $n$ platforms, numbered from $1$ to $n$ , placed one after another. There are $m$ colors available in the game, numbered from $1$ to $m$ . The $i$ -th platform is colored $c_i$ .
You start on the platform $1$ and want to reach platform $n$ . In one move, you can jump from some platform $i$ to platforms $i + 1$ or $i + 2$ .
All platforms are initially deactivated (including platforms $1$ and $n$ ). For each color $j$ , you can pay $x_j$ coins to activate all platforms of that color.
You want to activate some platforms so that you could start on an activated platform $1$ , jump through some activated platforms and reach an activated platform $n$ .
What's the smallest amount of coins you can spend to achieve that?
输入格式
The first line contains two integers $n$ and $m$ ( $2 \le n \le 3 \cdot 10^5$ ; $1 \le m \le 40$ ) — the number of platforms and the number of colors, respectively.
The second line contains $n$ integers $c_1, c_2, \dots, c_n$ ( $1 \le c_i \le m$ ) — the colors of the platforms.
The third line contains $m$ integers $x_1, x_2, \dots, x_m$ ( $1 \le x_i \le 10^7$ ) — the cost of activating all platforms of each color.
The second line contains $n$ integers $c_1, c_2, \dots, c_n$ ( $1 \le c_i \le m$ ) — the colors of the platforms.
The third line contains $m$ integers $x_1, x_2, \dots, x_m$ ( $1 \le x_i \le 10^7$ ) — the cost of activating all platforms of each color.
输出格式
Print the smallest amount of coins you can spend to activate some platforms so that you could start on an activated platform $1$ , jump through some activated platforms and reach an activated platform $n$ .
输入输出样例
输入 #1
5 3 1 3 2 3 1 1 10 100
输出 #1
11
输入 #2
5 3 1 3 2 3 1 1 200 20
输出 #2
21
输入 #3
4 2 2 2 1 1 5 5
输出 #3
10
输入 #4
10 10 3 8 6 2 10 5 2 3 7 3 9 7 4 2 1 8 2 6 2 2
输出 #4
15
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted