-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
34 lines (31 loc) · 706 Bytes
/
A.cpp
File metadata and controls
34 lines (31 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
int main(){
int t;
scanf("%d",&t);
int n,H,M,h,m;
while(t--){
scanf("%d",&n);
scanf("%d",&H);
scanf("%d",&M);
int ho,mo,diff;
int min =10000000;
for(int i=0;i<n;i++){
scanf("%d",&h);
scanf("%d",&m);
if((h<H)||(h==H && m<M))
h = 24+h;
diff = (h-H)*60 + (m-M);
if(min>diff){
min = diff;
ho = h-H;
mo = m-M;
if(mo<0){
ho = ho-1;
mo = mo+60;
}
}
}
printf("%d ",ho);
printf("%d\n",mo);
}
}