ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1070. Local Time

Help!! WA on 1st but test in example works!!!!
Posted by Koryakov Anton_ghost_Anigus 1 Feb 2006 20:08
program a_local_time_1070;

{$APPTYPE CONSOLE}
{  1070 Pascal }
var to1,to2,tp1,tp2:real;
min1,min2:integer;
dd1,dd2,dd:integer;
arrpl:array[1..6] of boolean;
cou:integer;

function dif(t1,t2:real):integer;
var st1,st2,st3,st4:integer;
m:boolean;
diff:integer;
begin
m:=false;
diff:=0;
st1:=trunc(t1);
st2:=trunc((t1-st1)*100);
st3:=trunc(t2);
st4:=trunc((t2-st3)*100);
if (st1=st3) and (st2=st4) then m:=true;
while m=false do
begin
inc(diff);
inc(st2);
if st2=60 then
begin
inc(st1);
st2:=0;
end;
if st1=24 then
begin
st1:=0;
end;
if (st1=st3) and (st2=st4) then m:=true;
end;
dif:=diff;
end;

begin
readln(to1,tp1);
readln(to2,tp2);
dd1:=dif(to1,tp1);
dd2:=dif(to2,tp2);


if dd1<dd2 then
for cou:=1 to 6 do
begin
min1:=60*cou+dd1;
min2:=dd2-60*cou;
if (min1-min2>-11) and (min1-min2<11) then arrpl[cou]:=true;
end
else
for cou:=1 to 6 do
begin
min1:=60*cou+dd2;
min2:=dd1-60*cou;
if (min1-min2>-11) and (min1-min2<11) then arrpl[cou]:=true;
end;

for cou:=1 to 6 do
if arrpl[cou]=true then dd:=cou;

writeln(dd);

end.
Unfortunately the first test is not always equal to the sample. The problem is rather difficult, but you can solve it (-)
Posted by Dmitry 'Diman_YES' Kovalioff 1 Feb 2006 22:34
Re: Unfortunately the first test is not always equal to the sample. The problem is rather difficult, but you can solve it (-)
Posted by chensqi 30 Nov 2008 08:46
ME TOO
I DON'T KONW WHY.
I CAN'T UNDERSTAND...