50193. Minimum Time Difference
難度:2/51
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
49
50
51
52#include <stdio.h>
int abs(int n){
if(n < 0) return -n;
return n;
}
int min(int a, int b){
if(a > b) return b;
return a;
}
int getsec(int t){
int ans = 0;
ans += t % 100;
t /= 100;
ans += (t % 100) * 60;
t /= 100;
ans += t * 60 * 60;
return ans;
}
int getstp(int s){
int h, m;
h = s / 3600;
s %= 3600;
m = s / 60;
s %= 60;
return (h * 10000) + (m * 100) + s;
}
int main(){
int t1, t2, s1, s2;
int temp;
int flag = 0;
int minsec = 100000;
while(scanf("%d", &t1) != EOF){
if(flag == 0){
t2 = t1;
flag = 1;
continue;
}
//printf("%d\n%d", s1, s2);
s1 = getsec(t1);
s2 = getsec(t2);
temp = abs(s1 - s2);
//printf("%d\n", temp);
minsec = min(temp, minsec);
t2 = t1;
}
printf("%d\n", minsec);
}