Chef TeamsProblem code: CTEAMS |
All submissions for this problem are available.
The executive chef is trying to bring some competitive spirit into his kitchen. He wants to split the chefs into two teams based on their age - he'll form the young and the old team. To make it fair, he will split them evenly or give the young team one person advantage when there is an odd number of chefs. Ages of all employees are unique. The executive chef also rated all chefs according to their cooking skills. Rating of a team is equal to the sum of ratings of its members. The chefs have developed a habit of coming to work late. The executive chef wants to keep the teams as fair as possible at all times and is therefore forced to change the teams each time one of the chefs comes to work in the morning. He needs your help with this task.
Input
The first line contains the number of chefs N. The following N lines describe the chefs in order as they come to work. Each chef is described by two integers, his or her age Ai and rating Ri.
Output
Every time a new chef joins the kitchen, output the absolute difference between team ratings.
Constraints
- 1 <= N <= 10^5
- 1 <= Ai <= 10^9
- 1 <= Ri <= 1000
Example
Input: 5 2 3 1 7 5 5 3 1 8 15 Output: 3 4 5 4 9
| Author: | thocevar |
| Date Added: | 13-04-2011 |
| Time Limit: | 3 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments

Fetching successful submissions

please describe the output
can anybody xplain the
@ar3_ar split in to 2 teams
@ar3_ar split in to 2 teams
@rijin pls xplain the output
@jravi96 case (3,1) young
@default1130 -- thnx a lot
im getting runtime error but
i am getting time limit
"Please do not discuss
One thing I am not clear on
Reread the problem statement
@Vishnutej i got runtime
how Time limit exceeded
is there any soln in
can this prob solve in
parameter has incomplete
the question is, in case of
now i understood :D ...
thanx a lot..
please explain the output
to balance the rating ....as
I am stuck with "Time limit
Can you pls clarify what is
on which base (age or rating)
@ar3_ar : on the basis of
in case(5,5) why we are
@all gave me 1more in & out
N=4, ages=[1 2 50 100] = is
My code is giving correct
wats the output if the inputs
5 {2-3}{3-4}{5-5}{3-2}{8-15}
sorry
@sachin : 3 2 3 5 10
@sachin @rijin i thnk it sud
Number of test cases is only
@sachin "he young team one
@ rijin den why in d sample
@tassi : check the
I am continuously getting TLE
Anyone ans plz : Number of
Please provide more test
Please note that discussing
a simple question: shall i
i mean this: {5} {2 3} 3 {1
You can do it either way. The
can anyone please tell how to
is there need to take var. T
or is this because of
By constraints as
Test cases in all problems
@admin and all: Plz explain
@tomaz_adm plz do reply......
The chefs are split by
i have tried 3 diff algos anf
Getting a runtime Error
@tomaz_adm: Is it necessary
Please check previous posts
@tomaz_adm:apologies and I
@admin Id 564179 Plzzz check
@admin Id 564179 Plzzz check
@admin...my code gives
@orion_88 yeah man keep
@tomaz_admin: i m getting
can anyone tell y wrong
what does 0M mean , i got it
Come on Guys! Age of 10^9.
I guess cooks are not human
The problem statement doesn't
then 1s is not fair at all...
@pikku That 1 had the unit of
Or rather milliseconds...
@rijin Can u illustrate what
@admin My code is executing
The judge is very slow. From
I gave up....TLE...cant
Is it possible that the Java
Hi, If I run a program
@tekas1234: Indeed! One of
Can I know the execution time
hard problem T_T
In my PC its gets only 3.123s
Contest Ended ; but y