CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Challenge 2013
    • May Cook-Off 2013
    • May Challenge 2013
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • Campus Chapters
    • Host your Contest
    • Go for Gold
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
    • Top Contributors on Discuss
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » October Challenge 2012 » Event Organizer

Event Organizer

Problem code: MAXCOMP

  • All Submissions

All submissions for this problem are available.

Chef Po has given an online advertisement to provide Event organizing services. Chef got a huge response for his advertisement. He got various orders to conduct the events from different organizations. In turn, Chef will receive a compensation depend upon the type of event and the total numbers of persons in the event. Chef has received N orders for conducting events in this weekend in all. As weekend consists of two days all events will take place during the period of 48 hours. For the i-th order the corresponding event will start at Si hours, ends at Ei hours and Chef will receive a compensation Ci for this event. For example, if Si = 17 and Ei = 22 then duration of event is 22 – 17 = 5 hours and its time period is 17:00 – 22:00 of Saturday. Hours of Sunday are numbered by numbers from 24 to 48. So, for example, 10:00 of Sunday will be represented as 10 + 24 = 34. Because Chef is a newbie, the organizations had put a condition that Chef will receive a compensation for the event if and only if he is available for the entire duration of the event. It means that he can not choose overlapping events. Note, however, that if some event starts just in the moment another event has finished the Chef can safely conduct them both.

In general Chef will obey the orders on first come first serve basis. But on weekends Chef will select the orders in such a way that the total compensation for all the events he will conduct will be the maximal. Now your task is to help Chef and find this maximal total compensation.

Input

The first line of the input contains an integer T, the number of test cases. T test cases follow. The first line of each test case contains an integer N, the number of received orders for conducting events. Each of the next N lines contains three space separated integers Si, Ei, Ci, the parameters of the i-th event described in the problem statement.

Constraints

1 ≤ T ≤ 10
1 ≤ N ≤ 2000
0 ≤ Si < Ei ≤ 48
0 ≤ Ci ≤ 106

Output

Output for each test case should contain a single integer in a separate line, the maximal compensation Chef Po can get.

Example

Input:
2
4
1 2 100
2 3 200
3 4 1600
1 3 2100
3
1 10 2000
2 5 100
6 9 400

Output:
3700
2000

Explanation

Case 1. The best choice here is to conduct 3rd and 4th events. The total compensation is equal to 1600 + 2100 = 3700. These events do not overlap since 3rd event starts just after the finish of the 4th one. Alternatively we can conduct first three events that also do not overlap. But in this case compensation will be only 100 + 200 + 1600 = 1900.

Case 2. Note that first event overlaps with both second and third events, while the last two events do not overlap. Hence there are two reasonable choices available for Chef. One is to take just the first order with total compensation 2000 and the second one is to take the last two orders with total compensation 100 + 400 = 500. Clearly the first choice is better. Hence the answer is 2000.


Author: khadarbasha
Tester: anton_lunyov
Editorial http://discuss.codechef.com/problems/MAXCOMP
Date Added: 31-05-2012
Time Limit: 1 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, FORT, FS, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

I can't submit this task -

stostap @ 1 Oct 2012 08:35 PM
I can't submit this task - when I press submit it redirect me to the main page. How I can submit? thx

@stostap Maybe this is

anton_adm @ 1 Oct 2012 08:48 PM
@stostap Maybe this is because you are using team account for the contest CODEFIN1. Try to use your usual account @spiker

i am definitely using more

shredder @ 2 Oct 2012 12:29 PM
i am definitely using more than 0M of memory submission id:1397108 http://www.codechef.com/OCT12/status/MAXCOMP,shredder is it because the program terminates prematurely?

@stostap: first login urself

tusharxps @ 2 Oct 2012 03:08 PM
@stostap: first login urself

do we have to print the max

ocozalp @ 2 Oct 2012 05:13 PM
do we have to print the max compensation total between (lowest time, highest time) interval? can we print the max value for any interval?

@ocozalp you just needs to

khad_adm @ 2 Oct 2012 05:23 PM
@ocozalp you just needs to print the maximum compensation that chef can able to make in weekends.

@shredder Your Program is

khad_adm @ 2 Oct 2012 05:27 PM
@shredder Your Program is terminated because of Wrong Answer But not because of memory issues...

@stostap login kr

avis408 @ 2 Oct 2012 08:26 PM
@stostap login kr

@all: please, do NOT ask for

betlista @ 4 Oct 2012 12:09 AM
@all: please, do NOT ask for help (including additional test cases, or complexity), read the guidelines - http://discuss.codechef.com/questions/855/what-kind-of-comment-should-i-... !!!

@admin - I have a doubt

anantkaushik89 @ 4 Oct 2012 09:00 AM
@admin - I have a doubt regarding the maximum value of N. The starting time of the event has to be less than ending time. So, starting from 0 and going till 48, we can have (49 * 48)/2 values for the possible competitions and this turns out to be 1176. I am unable to understand how can there be 2000 possible values. Please pardon me if I have misunderstood something.

@anantkaushik89 there will be

khad_adm @ 4 Oct 2012 10:27 AM
@anantkaushik89 there will be more than one order with the same start time.So in this case we can have any number of orders.

can the start and end time be

disastrous @ 4 Oct 2012 03:52 PM
can the start and end time be same?

@admin can there be two

nitish712 @ 4 Oct 2012 05:59 PM
@admin can there be two events with same starting & ending time???

@nitish,disastrous ...Please

khad_adm @ 4 Oct 2012 07:12 PM
@nitish,disastrous ...Please read the Constraints section properly

It should be 0 < Si < Ei ≤ 48

dummysg @ 4 Oct 2012 07:35 PM
It should be 0 < Si < Ei ≤ 48 . Dont u think so admin?

@disastrous No. It is clearly

anton_adm @ 4 Oct 2012 09:41 PM
@disastrous No. It is clearly mentioned in the Constraints section that Si < Ei @nitish712 You should understand the Constraints section precisely. There is nothing said about absence of two events with the same pair (Si, Ei). So it is possible. And in fact for N=2000 there always exist two such events. @dummysg. Si=0 is possible. It means that event starts just in the midnight between Friday and Saturday.

@admin: if i take s=0 & e=48,

dummysg @ 4 Oct 2012 11:45 PM
@admin: if i take s=0 & e=48, then its a 49 hours window instead of 48.. so isnt that wrong?!!...reconsider this case!!

@All who are getting WA .

khad_adm @ 5 Oct 2012 12:28 AM
@All who are getting WA . .Instead of only testing your program for the given test cases try to improve the test cases by your own...Because developing test cases is one of the problem solving strategy...

@dummysg for s=0, e=48

aamir @ 5 Oct 2012 03:20 PM
@dummysg for s=0, e=48 window will 48-0=48. An hour is a duration in time(0 to 1, 5 to 6, etc) not a point in time.

@admin ..do we have to check

vermansit @ 5 Oct 2012 06:40 PM
@admin ..do we have to check the condition for constraints

@vermansit no need to check

khad_adm @ 5 Oct 2012 07:01 PM
@vermansit no need to check the constraints........

do si and ei shoul be integer

codingrg @ 8 Oct 2012 04:56 PM
do si and ei shoul be integer values only or they can be float?

@codingrg si and ei should be

khad_adm @ 8 Oct 2012 05:55 PM
@codingrg si and ei should be integers....Please read the input section carefully....

When will the rest 3 problem

abhinav1592 @ 8 Oct 2012 07:05 PM
When will the rest 3 problem be uploaded????

can dynamic memory allocation

elva136 @ 10 Oct 2012 12:01 PM
can dynamic memory allocation be used in the programs?

i am not able to get my rank

betrayermor @ 12 Oct 2012 06:22 PM
i am not able to get my rank and rating even though i have submitted two problems.. it is written in my profile that they are not able to find any country code for me i req yu to advice a solution for this problem

sir pls respond to my comment

betrayermor @ 13 Oct 2012 08:50 PM
sir pls respond to my comment rank and rating develops the urge to go farther and farther!!

@betrayermor You can try this

anton_adm @ 13 Oct 2012 10:33 PM
@betrayermor You can try this link: http://www.codechef.com/rankings/OCT12. At the moment I write this comment you were 1424. But this ranking is unrelated to the contest. Since in fact you ties places from 1133 to 1489. That is, the only relevant thing is your score and not the penalty.

SUCCESSFUL SUBMISSIONS


Fetching successful submissions

CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.