Advertisement
a53

books

a53
Nov 5th, 2018
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #define Nmax 200001
  3. using namespace std;
  4. int n,a[Nmax],F[Nmax],x;
  5.  
  6. int main()
  7. {
  8. cin>>n;
  9. int i;
  10. for(i=1;i<=n;++i)
  11. cin>>a[i];
  12. i=1;
  13. int nrzero=n;
  14. while(i<=n)
  15. {
  16. cin>>x;
  17. int sol=0;
  18. while(!F[x])
  19. if(x!=a[i])
  20. F[a[i++]]=1,++sol;
  21. else
  22. ++i,++sol,F[x]=1;
  23. --nrzero,cout<<sol<<' ';
  24. }
  25. for(i=1;i<=nrzero;++i)
  26. cout<<0<<' ';
  27. cout<<'\n';
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement