codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

254B.md (2682B)


      1 Source: https://codeforces.com/problemset/problem/254/B
      2 
      3 B. Jury Size
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 input.txt
     16 
     17 output
     18 
     19 output.txt
     20 
     21 In 2013, the writers of Berland State University should prepare problems for *n* Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to *n*. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems for her. Namely, the Olympiad number *i* should be prepared by *p**i* people for *t**i* days, the preparation for the Olympiad should be a continuous period of time and end exactly one day before the Olympiad. On the day of the Olympiad the juries who have prepared it, already do not work on it.
     22 
     23 For example, if the Olympiad is held on December 9th and the preparation takes 7 people and 6 days, all seven members of the jury will work on the problems of the Olympiad from December, 3rd to December, 8th (the jury members won't be working on the problems of this Olympiad on December 9th, that is, some of them can start preparing problems for some other Olympiad). And if the Olympiad is held on November 3rd and requires 5 days of training, the members of the jury will work from October 29th to November 2nd.
     24 
     25 In order not to overload the jury the following rule was introduced: one member of the jury can not work on the same day on the tasks for different Olympiads. Write a program that determines what the minimum number of people must be part of the jury so that all Olympiads could be prepared in time.
     26 
     27 Input
     28 
     29 The first line contains integer *n* — the number of Olympiads in 2013 (1 ≤ *n* ≤ 100). Each of the following *n* lines contains four integers *m**i*, *d**i*, *p**i* and *t**i* — the month and day of the Olympiad (given without leading zeroes), the needed number of the jury members and the time needed to prepare the *i*-th Olympiad (1 ≤ *m**i* ≤ 12, *d**i* ≥ 1, 1 ≤ *p**i*, *t**i* ≤ 100), *d**i* doesn't exceed the number of days in month *m**i*. The Olympiads are given in the arbitrary order. Several Olympiads can take place in one day.
     30 
     31 Use the modern (Gregorian) calendar in the solution. Note that all dates are given in the year 2013. This is not a leap year, so February has 28 days. Please note, the preparation of some Olympiad can start in 2012 year.
     32 
     33 Output
     34 
     35 Print a single number — the minimum jury size.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 2  
     43 5 23 1 2  
     44 3 13 2 3
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 2
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 3  
     57 12 9 2 1  
     58 12 8 1 3  
     59 12 8 2 2
     60 ```
     61 
     62 Output
     63 
     64 ```
     65 3
     66 ```
     67 
     68 Input
     69 
     70 ```
     71 1  
     72 1 10 1 13
     73 ```
     74 
     75 Output
     76 
     77 ```
     78 1
     79 ```