#include<bits/stdc++.h>
using namespace std;
int leapyear(int y)
{
if(y%400 == 0 || (y%100 != 0 && y%4 == 0))
return 1;
else
return 0;
}
int check(int d, int m, int y, int pred, int prem, int prey)
{
if(d > 1)
{
if(pred+1 == d && prem == m && prey == y)
return 1;
}
else if(pred == 31 && d == 1 && prem == 12 && m == 1 && prey+1 == y)
return 1;
else if(prey == y && prem+1 == m)
{
if(m == 2 && pred == 31)
return 1;
else if(m == 3 && pred == 28 + leapyear(y))
return 1;
else if(m == 4 && pred == 31)
return 1;
else if(m == 5 && pred == 30)
return 1;
else if(m == 6 && pred == 31)
return 1;
else if(m == 7 && pred == 30)
return 1;
else if(m == 8 && pred == 31)
return 1;
else if(m == 9 && pred == 31)
return 1;
else if(m == 10 && pred == 30)
return 1;
else if(m == 11 && pred == 31)
return 1;
else if(m == 12 && pred == 30)
return 1;
}
return 0;
}
int main()
{
int n, i;
while(cin >> n && n != 0)
{
int d, m, y, tk, pred, prem, prey, pretk;
int c = 0, diff = 0;
for(i=0; i<n; i++)
{
cin >> d >> m >> y >> tk;
if(i > 0)
{
if(check(d, m, y, pred, prem, prey))
{
c++;
diff = diff + (tk - pretk);
}
}
pred = d, prem = m, prey = y, pretk = tk;
}
cout << c << " " << diff << "\n";
}
return 0;
}
Comments
Post a Comment