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 1880. Psych Up's Eigenvalues

time limit exceeded
Posted by IT 7 Mar 2016 18:17
var
A:array[1..4000] of integer;
B:array[1..4000] of integer;
C:array[1..4000] of integer;
q,w,e,r,t,y,i,o,p,s:integer;
begin
read(q);
for r:=1 to q do read(A[r]);
read(w);
for t:=1 to w do read(B[t]);
read(e);
for y:=1 to e do read(C[y]);
for i:=1 to q do begin
for o:=1 to w do
for p:=1 to e do
if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);
end;
write(s);
end.
Re: time limit exceeded
Posted by IlushaMax 8 Mar 2016 15:02
You should make variables like i1 ,i2, i3 but not q,w,e.r,t,y you know?
So your program isn't clear.
And about your timelimi.... :
put here
for o:=1 to w do
>>>
for p:=1 to e do
if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);
this: if A[i]=B[o] then begin
for p:=1 to e do
if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);end;
and...think about what you can delete from this:  if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);end;