nicuvlad76

Untitled

Jan 12th, 2021
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. ///coada alocata static
  2. #include <bits/stdc++.h>
  3. #define N 50001
  4. using namespace std;
  5. ifstream fin("coada1.in");
  6. ofstream fout("coada1.out");
  7.  
  8. int q[N], v[1001],n,x, indx,dim;
  9. char s[10];
  10. int main()
  11. {
  12. fin>>n;
  13. indx=0,dim=0;
  14. for(int i=1; i<=n; i++)
  15. {
  16. fin>>s>>x;
  17. if(s[0]=='p')
  18. {
  19. if(v[x]>indx)
  20. {
  21. indx=v[x],q[++dim]=x, v[x]=dim;
  22. }
  23. else if(v[x]<=indx)q[++dim]=x, v[x]=dim;
  24. }
  25. else
  26. {
  27. if(v[x]>indx)fout<<v[x]-indx<<"\n";
  28. else fout<<-1<<'\n';
  29. }
  30. }
  31. return 0;
  32. }
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment