QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100 Hackable ✓

#16767. 比利、威利和莫斯科地铁

Statistiques

2008年的全球经济危机影响了世界上的每一个人,也重创了许多行业。但富有的史高治·麦克老鸭(Scrooge McDuck)的生意受到的打击最为严重。他的金矿工厂开始亏损甚至破产。此外,美国政府还披露了史高治参与非法抵押贷款活动。他别无选择,只能离开美国前往国外。你猜怎么着?他选择了俄罗斯!

“史高治叔叔,我们想体验一下莫斯科地铁,帮我们买票吧!”来度假探望他们可怜叔叔的比利(Billy)和威利(Willy)说道。

“好吧,请等一下,”史高治叔叔若有所思地回答。他试图找出如何花最少的钱,同时又能让他的侄子们开心的方法。

由于史高治从来都不喜欢数学,他需要你的帮助。已知比利和威利将在莫斯科停留 $n$ 天。他们喜欢地铁,并希望花其中的一些天去探索它(每天最多出行一次)。其余的日子他们打算去参观高尔基公园。为了防止比利和威利之间发生争吵,即使他们一起乘坐地铁,史高治也需要给他们准备单独的票。在每天结束时,侄子们应该把票还给叔叔。史高治在莫斯科地铁有特殊关系,可以买到比普通人更便宜的票。

当然,他希望购买尽可能少数量的票,因此他需要决定每天早上给比利和威利哪张票。你被雇来帮助麦克老鸭解决这个棘手的问题!

注意,单张票允许你使用地铁不超过 $A$ 次,且第一次和最后一次使用之间的天数差必须小于 $B$(即若第一次在第 $d_1$ 天使用,最后一次在第 $d_2$ 天使用,则需满足 $d_2 - d_1 < B$)。

输入格式

第一行包含一个整数 $n$($1 \le n \le 200$)和两个整数 $A, B$($1 \le A, B \le 20$)。

第二行和第三行分别包含 $n$ 个数字 $a_1, a_2, \dots, a_n$ 和 $b_1, b_2, \dots, b_n$($a_i, b_i \in \{0, 1\}$)。

当且仅当 $a_i = 1$ 时,比利在第 $i$ 天使用地铁。当且仅当 $b_i = 1$ 时,威利在第 $i$ 天使用地铁。

输出格式

输出一个整数,表示史高治需要为比利和威利购买的最少车票数量。

样例

输入样例 1

2 5 5
1 1
0 0

输出样例 1

1

输入样例 2

2 5 5
1 0
0 1

输出样例 2

1

输入样例 3

11 20 10
1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0

输出样例 3

3

说明

在最后一个样例中,史高治应该在第一天给两张票,因此它们在第十一天时失效,他需要再给比利一张票。

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.