Saleh127

CF 1393B

Aug 7th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);
  7. cout.tie(0);
  8. int tt,a,n,d,e,f=0,i,j=0,k=0,l=0,o,p;
  9. int c[100005]={0};
  10. cin>>tt;
  11. for(i=0; i<tt; i++)
  12. {
  13. cin>>a;
  14. f=max(f,a);
  15. c[a]++;
  16. }
  17. for(i=1; i<=f; i++)
  18. {
  19. j+=(c[i]/4);
  20. k+=(c[i]%4)/2;
  21. }
  22. cin>>n;
  23. char x;
  24. while(n--)
  25. {
  26. cin>>x>>d;
  27. j-=(c[d]/4);
  28. k-=(c[d]%4)/2;
  29. if(x=='+')
  30. {
  31. c[d]++;
  32. }
  33. else
  34. {
  35. c[d]--;
  36. }
  37. j+=(c[d]/4);
  38. k+=(c[d]%4)/2;
  39. if(j>=2)
  40. {
  41. cout<<"YES"<<endl;
  42. }
  43. else if(j>=1 && k>=2)
  44. {
  45. cout<<"YES"<<endl;
  46. }
  47. else cout<<"NO"<<endl;
  48. }
  49. return 0;
  50. }
  51.  
Add Comment
Please, Sign In to add comment