-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path1714A.cpp
48 lines (40 loc) · 789 Bytes
/
1714A.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int H, M;
cin>>H>>M;
int h, m;
int timeh, timem, mintimeh = 24, mintimem = 60;
while(n--){
cin>>h>>m;
timeh = h - H;
timem = m - M;
if(timem < 0){
timem += 60;
timeh--;
}
if(timeh < 0){
timeh += 24;
}
if(timeh < mintimeh){
mintimeh = timeh;
mintimem = timem;
}
else if(timeh == mintimeh && timem < mintimem){
mintimem = timem;
}
}
cout<<mintimeh<<" "<<mintimem<<endl;
}
}