codeforces 155 Div2 B

B. Jury Size
time limit per test
1 second
memory limit per test
256 megabytes
input
input.txt
output
output.txt

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 pipeople 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 integersmidipi 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 ≤ 12di ≥ 11 ≤ 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.

Sample test(s)
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

很水的题。。开了个数组, 计算下哪天需要的人最多就可以了。可是 竟然re啊!!!原来要读文件的=-=。。。
代码:
 1 #include<stdio.h>
 2 
 3 int arr[466]={0};
 4 
 5 int main( void)
 6 {
 7     FILE *fin=fopen("input.txt", "r");
 8     FILE *fout=fopen("output.txt", "w");
 9     int amount, mon, day, peo, time, sum, ans=0;
10     int i, j;
11     fscanf(fin,"%d", &amount);
12     for( i=0; i<amount; i++)
13     {
14         sum=0;
15         fscanf(fin,"%d %d %d %d", &mon, &day, &peo, &time);
16         switch( mon)
17         {
18         case 12:sum+=30;
19         case 11:sum+=31;
20         case 10:sum+=30;
21         case 9:sum+=31;
22         case 8:sum+=31;
23         case 7:sum+=30;
24         case 6:sum+=31;
25         case 5:sum+=30;
26         case 4:sum+=31;
27         case 3:sum+=28;
28         case 2:sum+=31;
29         case 1:sum+=day;break;
30         }
31         sum+=100;
32         for( j=1; j<=time; j++)
33             arr[sum-j]+=peo;
34     }
35     for( i=0; i<466; i++)
36         ans=ans>=arr[i]?ans:arr[i];
37     fprintf(fout,"%d", ans);
38     return 0;
39 }

 

 

转载于:https://www.cnblogs.com/shadow-justice/archive/2012/12/27/2836395.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值