Why I get WA? Pelase, help me!!!!!!! My code: Program t1154;{$N+} Const Eps=1E-9; Type Mages=(A,E,F,W); Time=record H,Min,Sec :integer end; Var Info :array[Mages]of record TPower,TWeak :time; Power,Weak :integer; end; ch :char; S,Tmp :string[255]; L,D :array[Mages]of integer; CT,MinT :time; Per :array[1..9]of time; Max :extended; i,j,k,t :integer; Procedure GetTime(Str:string;Var T:Time); var i:integer; begin val(copy(str,1,2),T.H,i); val(copy(str,4,5),T.Min,i); val(copy(str,7,8),T.Sec,i); end; Function GetPower(TPower,TWeak,TCur:time;Power,Weak:integer):extended; var t0,t1,t2,t3,tc,t :extended; p0,p1,p2,p3,p :integer; begin t1:=TPower.H+TPower.Min/60+TPower.Sec/3600;p1:=Power; t2:=TWeak.H+TWeak.Min/60+TWeak.Sec/3600;p2:=Weak; tc:=TCur.H+TCur.Min/60+TCur.Sec/3600; if t1>t2 then begin t:=t1;t1:=t2;t2:=t; p:=p1;p1:=p2;p2:=p; end; t0:=t2-24;p0:=p2; t3:=t1+24;p3:=p1; if tc<t1 then t:=p0+(p1-p0)*((tc-t0)/(t1-t0)) else if tc<t2 then t:=p1+(p2-p1)*((tc-t1)/(t2-t1)) else if tc<t3 then t:=p2+(p3-p2)*((tc-t2)/(t3-t2)); GetPower:=t; end; Function GetMagesR(CTime:time):extended; var imp :array[mages]of extended; li,di :extended; begin imp[A]:=GetPower(Info[A].TPower,Info[A].TWeak,CTime,Info [A].Power,Info[A].Weak); imp[E]:=GetPower(Info[E].TPower,Info[E].TWeak,CTime,Info [E].Power,Info[E].Weak); imp[F]:=GetPower(Info[F].TPower,Info[F].TWeak,CTime,Info [F].Power,Info[F].Weak); imp[W]:=GetPower(Info[W].TPower,Info[W].TWeak,CTime,Info [W].Power,Info[W].Weak); li:=imp[A]*l[A]+imp[E]*l[E]+imp[F]*l[F]+imp[W]*l[W]; di:=imp[A]*d[A]+imp[E]*d[E]+imp[F]*d[F]+imp[W]*d[W]; GetMagesR:=li-di; end; begin for i:=1 to 4 do begin Readln(S); S:=S+' '; ch:=S[1]; for j:=2 to length(s) do if s[j]<>' ' then break; if ch='A' then GetTime(copy(s,j,8),Info[A].TPower); if ch='E' then GetTime(copy(s,j,8),Info[E].TPower); if ch='F' then GetTime(copy(s,j,8),Info[F].TPower); if ch='W' then GetTime(copy(s,j,8),Info[W].TPower); j:=j+8; for k:=j to length(s) do if s[k]<>' ' then break; Tmp:=''; while s[k]<>' ' do begin Tmp:=Tmp+s[k];k:=k+1; end; if ch='A' then Val(Tmp,Info[A].Power,t); if ch='E' then Val(Tmp,Info[E].Power,t); if ch='F' then Val(Tmp,Info[F].Power,t); if ch='W' then Val(Tmp,Info[W].Power,t); for j:=k to length(s) do if s[j]<>' ' then break; if ch='A' then GetTime(copy(s,j,8),Info[A].TWeak); if ch='E' then GetTime(copy(s,j,8),Info[E].TWeak); if ch='F' then GetTime(copy(s,j,8),Info[F].TWeak); if ch='W' then GetTime(copy(s,j,8),Info[W].TWeak); j:=j+8; for k:=j to length(s) do if s[k]<>' ' then break; Tmp:=''; while s[k]<>' ' do begin Tmp:=Tmp+s[k];k:=k+1; end; if ch='A' then Val(Tmp,Info[A].Weak,t); if ch='E' then Val(Tmp,Info[E].Weak,t); if ch='F' then Val(Tmp,Info[F].Weak,t); if ch='W' then Val(Tmp,Info[W].Weak,t); end; FillChar(L,SizeOf(L),0); FillChar(D,SizeOf(D),0); ch:=' '; While (ch<>#10)and(ch<>#13)and(ch<>#26) do begin read(ch); Case ch of 'A': Inc(L[A]); 'E': Inc(L[E]); 'F': Inc(L[F]); 'W': Inc(L[W]); end; end; read(ch); ch:=' '; While (ch<>#10)and(ch<>#13)and(ch<>#26) do begin read(ch); Case ch of 'A': Inc(D[A]); 'E': Inc(D[E]); 'F': Inc(D[F]); 'W': Inc(D[W]); end; end; read(ch); MinT.H:=0; MinT.Min:=0; MinT.Sec:=0; Max:=GetMagesR(MinT); per[1].H:=23; per[1].Min:=59; per[1].Sec:=59; per[2]:=Info[A].TPower; per[3]:=Info[E].TPower; per[4]:=Info[F].TPower; per[5]:=Info[W].TPower; per[6]:=Info[A].TWeak; per[7]:=Info[E].TWeak; per[8]:=Info[F].TWeak; per[9]:=Info[W].TWeak; for i:=1 t Re: I get AC. To everybody (+) > My code: > > Program t1154;{$N+} > > Const Eps=1E-9; > > Type Mages=(A,E,F,W); > Time=record H,Min,Sec :integer end; > > Var Info :array[Mages]of record > TPower,TWeak :time; > Power,Weak :integer; > end; > ch :char; > S,Tmp :string[255]; > L,D :array[Mages]of integer; > CT,MinT :time; > Per :array[1..9]of time; > Max :extended; > i,j,k,t :integer; > > Procedure GetTime(Str:string;Var T:Time); > var i:integer; > begin > val(copy(str,1,2),T.H,i); > val(copy(str,4,5),T.Min,i); > val(copy(str,7,8),T.Sec,i); > end; > > Function GetPower (TPower,TWeak,TCur:time;Power,Weak:integer):extended; > var t0,t1,t2,t3,tc,t :extended; > p0,p1,p2,p3,p :integer; > begin > t1:=TPower.H+TPower.Min/60+TPower.Sec/3600;p1:=Power; > t2:=TWeak.H+TWeak.Min/60+TWeak.Sec/3600;p2:=Weak; > tc:=TCur.H+TCur.Min/60+TCur.Sec/3600; > if t1>t2 then begin > t:=t1;t1:=t2;t2:=t; > p:=p1;p1:=p2;p2:=p; > end; > t0:=t2-24;p0:=p2; > t3:=t1+24;p3:=p1; > if tc<t1 then > t:=p0+(p1-p0)*((tc-t0)/(t1-t0)) else > if tc<t2 then > t:=p1+(p2-p1)*((tc-t1)/(t2-t1)) else > if tc<t3 then > t:=p2+(p3-p2)*((tc-t2)/(t3-t2)); > GetPower:=t; > end; > > Function GetMagesR(CTime:time):extended; > var imp :array[mages]of extended; > li,di :extended; > begin > imp[A]:=GetPower(Info[A].TPower,Info[A].TWeak,CTime,Info > [A].Power,Info[A].Weak); > imp[E]:=GetPower(Info[E].TPower,Info[E].TWeak,CTime,Info > [E].Power,Info[E].Weak); > imp[F]:=GetPower(Info[F].TPower,Info[F].TWeak,CTime,Info > [F].Power,Info[F].Weak); > imp[W]:=GetPower(Info[W].TPower,Info[W].TWeak,CTime,Info > [W].Power,Info[W].Weak); > li:=imp[A]*l[A]+imp[E]*l[E]+imp[F]*l[F]+imp[W]*l[W]; > di:=imp[A]*d[A]+imp[E]*d[E]+imp[F]*d[F]+imp[W]*d[W]; > GetMagesR:=li-di; > end; > > begin > for i:=1 to 4 do begin > Readln(S); > S:=S+' '; > ch:=S[1]; > for j:=2 to length(s) do > if s[j]<>' ' then break; > if ch='A' then GetTime(copy(s,j,8),Info[A].TPower); > if ch='E' then GetTime(copy(s,j,8),Info[E].TPower); > if ch='F' then GetTime(copy(s,j,8),Info[F].TPower); > if ch='W' then GetTime(copy(s,j,8),Info[W].TPower); > j:=j+8; > for k:=j to length(s) do > if s[k]<>' ' then break; > Tmp:=''; > while s[k]<>' ' do begin Tmp:=Tmp+s[k];k:=k+1; end; > if ch='A' then Val(Tmp,Info[A].Power,t); > if ch='E' then Val(Tmp,Info[E].Power,t); > if ch='F' then Val(Tmp,Info[F].Power,t); > if ch='W' then Val(Tmp,Info[W].Power,t); > for j:=k to length(s) do > if s[j]<>' ' then break; > if ch='A' then GetTime(copy(s,j,8),Info[A].TWeak); > if ch='E' then GetTime(copy(s,j,8),Info[E].TWeak); > if ch='F' then GetTime(copy(s,j,8),Info[F].TWeak); > if ch='W' then GetTime(copy(s,j,8),Info[W].TWeak); > j:=j+8; > for k:=j to length(s) do > if s[k]<>' ' then break; > Tmp:=''; > while s[k]<>' ' do begin Tmp:=Tmp+s[k];k:=k+1; end; > if ch='A' then Val(Tmp,Info[A].Weak,t); > if ch='E' then Val(Tmp,Info[E].Weak,t); > if ch='F' |