Relive the World Cup

Source: Internet
Author: User
Description
At the end of the World Cup, the Italians brought back the French debt owed to them 6 years ago and took up the cup of the Hercules, making 4-Star Italy.
The World Cup is over, but the World Cup has left us with a lot to remember. For example, we heard the yellow name of the mouth of the 3-minute passionate commentary, we learned that the original can be presented to the same person 3 yellow cards, we also saw Zidane's head can not only ball can also top people ...
There are so many wonderful, Xhd decided to revisit the German World Cup, of course, just go to the host World Cup tournament to take a look at the city. But it takes a lot of money, and fortunately Xhd's love for the World Cup has moved the World Cup organizing Committee, They will provide a round-trip ticket to the city of Xhd in China, Hangzhou and Germany, and persuade the cities to provide him with a living allowance when Xhd arrives in the city, so that when he visits there, the rest of the money will be left to XHD, But when the cost of living is not enough, they will force the end of XHD's trip to Germany, in addition to this, they have a condition, XHD only according to their route to visit. For example, there are 3 cities a,b,c, they given a-b-c-a route, then XHD only 3 kinds of tour order ABC,BCA, Cab. Because the cost of living and spending there are different in each city, it makes XHD very headache, fortunately we know the cost of living and expenses in advance. How many cities can XHD visit?
Input
Each set of input data is divided into two lines, and the first line is a positive integer n (1<=n<=100000), indicating that there are N cities. The next line is the output of the N cities in accordance with the given route order. The cost of living and spending, W1,l1,w2,l2,......, Wn,ln, of which WI, Li represents the cost of living and spending for the first city, and they are all positive integers.
Output
The maximum number of cities that can be visited for each set of data output.
Sampleinput
33 2 3 4 2 233 2 3 4 2 3
Sampleoutput
32

Relive the World Cup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.