描述:
For the health’s sake, Mr. Doraemonok drinks one and only one package of pure milk every day. However, Mr. Doraemonok will never drink sour milk which is out of storage period. When coming to them, he will throw them away. To save money, he wishes to save milk as much as possible. Considering these factors, he starts to check the milk stored in his closet to decide the drinking sequence. Can you offer a hand to him?
输入:
The first line of the input data will be a positive integer n (n<=100000) to represent the amount of the milk. Every one of the following n lines describes a package of milk: The first string stands for the brand of the milk, the second string stands for the production date, and the format is like ’03-20’. The n+2 line will be a positive integer m (m<=50) which stands for the number of the milk brands. Every line of the following m lines describes a milk brands: The first string is the name of the brand which is no longer than 20 characters and with no blanks. The following positive integer in this line stands for the storage period D (D<=45). All the milk brands in the problem will be listed. The last line will include a string which stands for today’s date. Mr. Doraemonok has not drunk milk today.
The dates in the input data are all in the range of Year 2008. The just out-of-date day should be considered out of date. Sample Input/Output and Hint can be references. We guaranteed that the data is right logically.
输出:
Output one line which includes only one nonnegative integer to represent the least amount of milk to be wasted.
样例:
3
Haihe_Pure_Milk 03-01
Haihe_Pure_Milk 03-01
Mengniu_Pure_Milk 03-20
2
Haihe_Pure_Milk 30
Mengniu_Pure_Milk 30
03-30
1
给出n行牛奶的名字和生产日期,给出m行牛奶的名字与保质期,再给出今天的日期。
下面的代码大概就是把每个牛奶过期的日子全存起来,然后将一天过期的牛奶存着。
776MS的我不争气的流下眼泪。
#include
using namespace std;
int d[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
struct p{
string s;
int mm,dd,day;
}a[100005];
bool cmp(p a,p b)
{
return a.day qy;
int n,m,p[600]={0};
cin>>n;
for(int i=0;i>a[i].s;
scanf("%d-%d",&a[i].mm,&a[i].dd);
a[i].day=a[i].dd;
for(int j=1;j>m;
while(m--)
{
string s;
int time;
cin>>s>>time;
qy[s]=time;
}
for(int i=0;i