#include<bits/stdc++.h>
using namespace std;
int main()
{
int h1, h2, m1, m2, t, n, i, c, need, j = 1;
char ch;
cin >> t;
while(t--)
{
cin >> n >> h1 >> ch >> m1;
set<int>s;
c = 0;
if(h1 == 0)
h1 = 24;
int t1 = (h1*60) + m1;
for(i=1; i<=n; i++)
{
cin >> h2 >> ch >> m2 >> need;
if(h2 == 0)
h2 = 24;
int t2 = 0;
if(h1 > h2 || (h1 == h2 && m1 > m2))
t2 = (24+h2)*60 + m2 + need;
else
t2 = (h2*60) + m2 + need;
c = t2 - t1;
s.insert(c);
}
auto it = s.begin();
cout << "Case " << j++ << ": " << *it << "\n";
}
return 0;
}
using namespace std;
int main()
{
int h1, h2, m1, m2, t, n, i, c, need, j = 1;
char ch;
cin >> t;
while(t--)
{
cin >> n >> h1 >> ch >> m1;
set<int>s;
c = 0;
if(h1 == 0)
h1 = 24;
int t1 = (h1*60) + m1;
for(i=1; i<=n; i++)
{
cin >> h2 >> ch >> m2 >> need;
if(h2 == 0)
h2 = 24;
int t2 = 0;
if(h1 > h2 || (h1 == h2 && m1 > m2))
t2 = (24+h2)*60 + m2 + need;
else
t2 = (h2*60) + m2 + need;
c = t2 - t1;
s.insert(c);
}
auto it = s.begin();
cout << "Case " << j++ << ": " << *it << "\n";
}
return 0;
}
Comments
Post a Comment