F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Traversal

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1342    Accepted Submission(s): 471


Problem Description
Xiao Ming is travelling, and today he came to the West Lake, to see people playing a game, this game is like this, lake placed n-box, from 1 to n label. These boxes are floating in the water, there are some gold inside each box. Then participants from coast to jump the other side, each box have its¡¯s height, you can only jump from lower height to higher height, and from a small label to a big label, you can skip some of the middle of the box. Suppose the minimum height is this side, the other side has the maximum height. Xiao Ming would like to jump how to get the most gold? He now needs your help.
 

Input
There are multiple test cases. Each test case contains one integer N , representing the number of boxes . The following N lines each line contains two integers hi and gi , indicate the height and the number of gold of the ith box.
1 < = N < 100 001
0 < hi < 100 000 001
0 < gi < = 10000
 

Output
For each test case you should output a single line, containing the number of maximum gold XiaoMing can get.

 

Sample Input
4 1 1 2 2 2 3 5 1 1 1 10000
 

Sample Output
5 10000
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 12:43:44, Gzip enabled