CF586B.Laurenty and Shop
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A little boy Laurenty has been playing his favourite game Nota for quite a while and is now very hungry. The boy wants to make sausage and cheese sandwiches, but first, he needs to buy a sausage and some cheese.
The town where Laurenty lives in is not large. The houses in it are located in two rows, n houses in each row. Laurenty lives in the very last house of the second row. The only shop in town is placed in the first house of the first row.
The first and second rows are separated with the main avenue of the city. The adjacent houses of one row are separated by streets.
Each crosswalk of a street or an avenue has some traffic lights. In order to cross the street, you need to press a button on the traffic light, wait for a while for the green light and cross the street. Different traffic lights can have different waiting time.
The traffic light on the crosswalk from the j-th house of the i-th row to the (j + 1)-th house of the same row has waiting time equal to a__ij (1 ≤ i ≤ 2, 1 ≤ j ≤ n - 1). For the traffic light on the crossing from the j-th house of one row to the j-th house of another row the waiting time equals b__j (1 ≤ j ≤ n). The city doesn't have any other crossings.
The boy wants to get to the store, buy the products and go back. The main avenue of the city is wide enough, so the boy wants to cross it exactly once on the way to the store and exactly once on the way back home. The boy would get bored if he had to walk the same way again, so he wants the way home to be different from the way to the store in at least one crossing.
Figure to the first sample.
Help Laurenty determine the minimum total time he needs to wait at the crossroads.
一个小男孩劳伦蒂(Laurenty)玩他最喜欢的游戏《Nota》已经很久了,现在非常饿。他想做香肠奶酪三明治,但首先需要买一根香肠和一些奶酪。
劳伦蒂居住的城镇并不大:房屋排成两行,每行有 $ n $ 座房屋。劳伦蒂住在第二行的最后一座房屋中。镇上唯一的商店位于第一行的第一座房屋中。
第一行与第二行之间被城市主干道隔开;同一行中相邻的房屋之间则由街道分隔。
每条街道或主干道上的斑马线处都设有交通信号灯。要穿过街道,需按下交通灯按钮,等待一段时间直至绿灯亮起,然后才能通行。不同交通灯的等待时间可能不同。
从第 $ i $ 行第 $ j $ 座房屋通往同一行第 $ j+1 $ 座房屋的斑马线处交通灯等待时间为 $ a_{ij} $(其中 $ 1 \le i \le 2 , 1 \le j \le n-1 $);而从某一行第 $ j $ 座房屋通往另一行第 $ j $ 座房屋的斑马线处交通灯等待时间为 $ b_j $(其中 $ 1 \le j \le n $)。该城市不存在其他任何斑马线。
男孩希望前往商店购买食材,再返回家中。由于主干道足够宽阔,他要求:在去商店的路上恰好穿越主干道一次,回家的路上也恰好穿越主干道一次。此外,为避免重复行走而感到无聊,他要求回家的路径与去商店的路径至少在一个斑马线处不同。
第一个样例示意图。
请帮助劳伦蒂计算他在所有斑马线处所需等待的最短总时间。
输入格式
The first line of the input contains integer n (2 ≤ n ≤ 50) — the number of houses in each row.
Each of the next two lines contains n - 1 space-separated integer — values a__ij (1 ≤ a__ij ≤ 100).
The last line contains n space-separated integers b__j (1 ≤ b__j ≤ 100).
输入的第一行包含一个整数 n(2≤n≤50)—— 表示每行的房屋数量。
接下来的两行,每行包含 n−1 个用空格分隔的整数 —— 即值 aij(1≤aij≤100)。
最后一行包含 n 个用空格分隔的整数 bj(1≤bj≤100)。
输出格式
Print a single integer — the least total time Laurenty needs to wait at the crossroads, given that he crosses the avenue only once both on his way to the store and on his way back home.
输出一个整数——即劳伦蒂在十字路口需要等待的最短总时间,前提是他在去商店和回家途中各仅穿越大道一次。
输入输出样例
输入#1
4 1 2 3 3 2 1 3 2 2 3
输出#1
12
输入#2
3 1 2 3 3 2 1 3
输出#2
11
输入#3
2 1 1 1 1
输出#3
4
说明/提示
The first sample is shown on the figure above.
In the second sample, Laurenty's path can look as follows:
- Laurenty crosses the avenue, the waiting time is 3;
- Laurenty uses the second crossing in the first row, the waiting time is 2;
- Laurenty uses the first crossing in the first row, the waiting time is 1;
- Laurenty uses the first crossing in the first row, the waiting time is 1;
- Laurenty crosses the avenue, the waiting time is 1;
- Laurenty uses the second crossing in the second row, the waiting time is 3.
In total we get that the answer equals 11.
In the last sample Laurenty visits all the crossings, so the answer is 4.
第一个样例如上图所示。
在第二个样例中,劳伦蒂的路径可以如下所示:
- 劳伦蒂穿越大道,等待时间为 3;
- 劳伦蒂使用第一行的第二个过街口,等待时间为 2;
- 劳伦蒂使用第一行的第一个过街口,等待时间为 1;
- 劳伦蒂再次使用第一行的第一个过街口,等待时间为 1;
- 劳伦蒂穿越大道,等待时间为 1;
- 劳伦蒂使用第二行的第二个过街口,等待时间为 3。
总计,答案为 11。
在最后一个样例中,劳伦蒂访问了所有过街口,因此答案为 4。
输入解题思路,AI测评打分。不知道怎么写?