CodeForces - 254B:Jury Size(思维、模拟)

Discription
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 pi people for ti 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.

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.

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.

Input
The first line contains integer n — the number of Olympiads in 2013 (1 ≤ n ≤ 100). Each of the following n lines contains four integers mi, di, pi and ti — 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 ≤ mi ≤ 12, di ≥ 1, 1 ≤ pi, ti ≤ 100), di doesn’t exceed the number of days in month mi. The Olympiads are given in the arbitrary order. Several Olympiads can take place in one day.

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.

Output
Print a single number — the minimum jury size.

Examples
Input

2
5 23 1 2
3 13 2 3

Output

2

Input

3
12 9 2 1
12 8 1 3
12 8 2 2

Output

3

Input

1
1 10 1 13

Output

1

题意
输入n组数。每一组四个数:m,d,p,t。
m代表活动开始月份(截至时间——月份);
d代表活动开始天数(截止时间——天数);
p代表在这但时间内每天需要的人数;
t活动的准备时间,即截止时间向前推t天。
求出所特有的活动一共最少需要多少人。

思路
将时间转化成数字,,用数字做下标,记录每天的人数,求最大值。记录的是每一天,而不是区间。
记录区间的最大值就错了!

AC代码

#include
using namespace std;
int mon[14]= {0,31,28,31,30,31,30,31,31,30,31,30,31};
int n,ans;
int m,d,p,t;
int day[510],month[15];
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false);
    cin>>n;
    int l=0,r=0;
    for(int i=1;i<=12;i++)
        month[i]=month[i-1]+mon[i];
    for(int i=1;i<=n;i++)
    {
        cin>>m>>d>>p>>t;
        m--;//开始没有减一,就错了
        r=month[m]+d+100;
        l=r-t;
        for(int j=l;j

你可能感兴趣的:(解题报告,思维)