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

Lie

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 159    Accepted Submission(s): 76


Problem Description
There are N students in a grade, each student belongs to only one class.Now all they standing in a row,but students in the same class are not necessarily going to stand together. Everyone will say a sentence like "Well,there are Ai my classmates stand on my left,as well as Bi my classmates on the right".But not everyone will tell the truth,the teacher also forgot their order of speech.Now the teacher want to know maximum number of people say without contradiction.
 

Input
There are multiple test cases, no more than 100 cases.
In each test case, the first line contains a single integer N.$(1\leq N\leq 1000 )$
The following N lines specify the people. Each of them contains two integers Ai and Bi separated by single spaces.$(0\leq Ai,Bi\leq 1000 )$
 

Output
For each test case,output the answer in a line.
 

Sample Input
3 0 2 2 0 3 0 5 0 0 1 0 0 0 0 0 0 0
 

Sample Output
2 4
 

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-04-25 20:38:23, Gzip enabled