using
System;
using
System.Collections.Generic;
using
System.Collections;
using
System.Linq;
class
ReadTime {
public
int
hh;
public
int
mm;
public
int
ss;
}
class
ChangeTime {
public
static
ReadTime res =
new
ReadTime();
public
static
ReadTime res1 =
new
ReadTime();
public
void
readTime(
string
time, ReadTime res)
{
string
s = time;
string
[] values = s.Split(
":"
);
res.hh = Convert.ToInt32(values[0]);
res.mm = Convert.ToInt32(values[1]);
res.ss = Convert.ToInt32(values[2]);
}
public
int
findMinOperations(
string
original_time,
string
new_time)
{
readTime(original_time, res);
int
ots = 3600 * res.hh + 60 * res.mm + res.ss;
readTime(new_time, res1);
int
nts = 3600 * res1.hh + 60 * res1.mm + res1.ss;
int
gre = Math.Max(ots, nts);
int
sma = Math.Min(ots, nts);
gre = gre - sma;
int
[] diff = { gre, 86400 - gre };
int
[] ope =
new
int
[2];
for
(
int
i = 0; i < 2; i++) {
ope[i] = diff[i] / 3600;
diff[i] = diff[i] % 3600;
if
(diff[i] > 1830) {
ope[i]++;
diff[i] = 3600 - diff[i];
}
ope[i] = ope[i] + diff[i] / 60;
diff[i] = diff[i] % 60;
if
(diff[i] > 30) {
ope[i]++;
diff[i] = 60 - diff[i];
}
ope[i] = ope[i] + diff[i];
}
return
Math.Min(ope[0], ope[1]);
}
static
void
Main() {
string
original_time =
"10:05:04"
;
string
new_time =
"02:34:12"
;
ChangeTime obj =
new
ChangeTime();
Console.WriteLine(obj.findMinOperations(original_time, new_time));
}
}