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

program m;
var a:array[1..4000] of integer;
    p:array[1..4000] of integer;
    x:array[1..4000] of integer;
    n,s,i,j,k,f,m:integer;
    begin
    read(n);
    for i:=1 to n do
    read(a[i]);
    read(s);
    for j:=1 to s do
    read(p[j]);
    read(k);
    for f:=1 to k do
    read(x[f]);m:=0;
for i:=1 to n do
        for j:=1 to s do
          for f:=1 to k do
          begin
           if (a[i]=p[j]) and (p[j]=x[f]) and (x[f]=a[i]) then
         m:=m+1;
         end;
         write(m);
         end.
Smilodon_am [Obninsk INPE] Re: Pascal?????в чем ошибка? // Problem 1880. Psych Up's Eigenvalues 19 Dec 2017 23:49
Your algo has complexity O(n1*n2*n3) id est 4000*4000*4000= 6.4*10^10. It's too much operations for one half a second. Try to use other algo instead of linear search twice.