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

Speed Dog

Time Limit: 4000/4000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 378    Accepted Submission(s): 112


Problem Description
Sunset and Elephant formed a programming contest team named ``Speed Dog''. There are $n$ problems in the online judge, labeled by $1,2,\dots,n$.

For the $i$-th problem, Sunset needs to code $a_i$ bytes while Elephant needs to code $b_i$ bytes. But they can work on problems together. Specifically, for the $i$-th problem, they can choose a real number $x_i(0\leq x_i\leq 1)$, split this problem into two parts $A$ and $B$, then assign Sunset to code part $A$ and assign Elephant to code part $B$. As a result, Sunset will code $a_i\times x_i$ bytes, and Elephant will code $b_i\times(1-x_i)$ bytes.

Now they want to solve all the problems whose labels are not larger than $k$. Assume Sunset codes $X$ bytes in total and Elephant codes $Y$ bytes in total. It is too tired for a coder to code too much code. Please help them find an assignment that $\max(X,Y)$ is minimized.
 

Input
The first line of the input contains an integer $T(1\leq T\leq 10000)$, denoting the number of test cases.

In each test case, there is one integer $n(1\leq n\leq 250000)$ in the first line, denoting the number of problems.

For the next $n$ lines, each line contains two integers $a_i,b_i(1\leq a_i,b_i\leq 1000)$, denoting each problem.

It is guaranteed that $\sum n\leq 10^6$.
 

Output
For each test case, print $n$ lines in format $\texttt{u/v}$, where the $i$-th line denotes the minimum value of $\max(X,Y)$ when $k=i$. Note that you should guarantee that $\gcd(u,v)=1$.
 

Sample Input
1 3 1 3 3 1 2 2
 

Sample Output
3/4 1/1 2/1
 

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-24 06:32:09, Gzip enabled