【编程题解】One piece

路飞在伟大航路上寻找一片,面对众多海盗的阻挠,他必须战胜足够强大的海盗才能获得护航。本篇分析了路飞如何计算所需最小力量值以确保在不被击败的情况下成功穿越伟大航线。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Description

Luffy wants to find one piece through the great route, and there are many other pirates on the road to stop him.

He knew that as long as he defeated the pirate with some physical strength, the pirate would always escort him.

On the way, he will meet N pirates in turn, each pirate has its own force value and the physical value required to defeat him.

If Luffy did not defeat a certain pirate, and this pirate's force value was greater than the sum of the pirate's force value escorting him, the pirate would defeat him.

Luffy wants to know that if he wants to successfully cross a great route without being defeated, he needs at least as much physical strength

 

Input

The first line contains the integer N, indicating the number of pirates.

The second line contains N integers d1, d2, ..., dn, which represent the force value of each pirate.

The third line contains N integers p1, p2, ..., pn, which represent the physical value required to defeat N pirates.

Data range:1≤N≤50,1≤di≤10^12,1≤pi≤2

 

Output

An integer is output, indicating the minimum physical strength required.

Sample Input 1 

3
8 5 10
1 1 2

Sample Output 1

2

 

Personal Answer  (using language:JAVA)  Not necessarily right

public class Main {
    public static void main(String[] args) {
        System.out.println("Unsolved");
    }
}

Welcome to communicate!

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值