#define LL long long
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<n;i++)
#define REV(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define pri(a) cout<<a<<endl
#define prii(a,b) cout<<a<<" "<<b<<endl
#define priii(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define hi printf("Hello World\n");
#define pcs printf("Case %d: ", ++cs);
using namespace std;
const int INF = 1<<29;
const int MX = 500+10;
int main()
{
int mnt,n,T,sth,stm,edh,edm,tmi,tmf,cs=0;
char ch;
cin>>T;
vector <int> vec;
while(T--)
{
vec.clear();
cin>>n;
cin >> sth >> ch >> stm;
tmi = stm + sth*60;
while(n--)
{
cin >> edh >> ch >> edm;
cin >> mnt;
tmf = edm + edh*60;
if(tmf<tmi) tmf+=1440;
tmf = tmf + mnt - tmi;
vec.push_back(tmf);
}
sort(ALL(vec));
printf("Case %d: ", ++cs);
pri(vec[0]);
}
return 0;
}
No comments:
Post a Comment