Description
Input
Output
Sample Input
4
2 120
1 2013-07-01 15:59 2013-07-08 16:30
2 2013-07-08 17:30 2013-07-15 12:00
3 60
65 2013-07-08 14:30 2013-07-08 16:00
32 2013-07-01 16:00 2013-07-15 12:00
91 2013-07-01 16:00 2013-07-08 15:00
2 360
a7 2016-02-21 14:00 2016-02-28 21:00
xx 2016-03-01 01:00 2016-03-02 12:57
2 60
a9 2016-02-21 14:00 2016-02-28 11:00
a8 2016-02-28 12:00 2016-03-11 21:00
Sample Output
2
3
1
1
HINT
Source
模拟。。。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int t[5][15];
struct node
{
int num;
int num1;
} s[5005];
bool vist[5005];
int flg[5005];
int cmp(const node p,const node p1)
{
if(p.num<p1.num) return 1;
else if(p.num==p1.num&&p.num1<p1.num1)
return 1;
else return 0;
}
int solve(int Y,int M,int D,int h,int m)
{
int d;
d = (Y - 2013) * 365 + (M - 1) * 30 + (D - 1);
if (M > 2)
{
d--;
if (Y % 4) d--;
}
while (--M)
{
if ((M <= 7 && M % 2) || (M > 7 && !(M % 2))) d++;
}
return m + 60 * (h + 24 * d);
}
int main()
{
int sum=0;
memset(t,0,sizeof(t));
int text;
scanf("%d",&text);
while(text--)
{
int n,m;
scanf("%d%d",&n,&m);
memset(vist,false,sizeof(vist));
memset(flg,0,sizeof(flg));
for(int i=0; i<n; i++)
{
int year,mon,day,h,mn;
char ch[100];
scanf("%s %d-%d-%d %d:%d",ch,&year,&mon,&day,&h,&mn);
s[i].num=solve(year,mon,day,h,mn);
scanf("%d-%d-%d %d:%d",&year,&mon,&day,&h,&mn);
s[i].num1=solve(year,mon,day,h,mn)+m;
}
sort(s,s+n,cmp);
int ans=1;
vist[0]=true;
flg[0]=s[0].num1;
for(int i=1; i<n; i++)
{
int w=0,x=-1;
for(int j=0; j<i; j++)
{
if(i==j) continue;
if(vist[j]&&flg[j]<=s[i].num)
{
w=1;
x=j;
break;
}
}
if(w==0)
{
vist[i]=true;
flg[i]=s[i].num1;
ans++;
}
else
{
flg[x]=s[i].num1;
}
}
printf("%d\n",ans);
}
return 0;
}