Advertisement
daniv1

Untitled

Feb 23rd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. #include <list>
  4.  
  5. using namespace std;
  6. int main()
  7. {
  8. size_t n;
  9. cin>>n;
  10. std::vector<int> b;
  11. int sum = 0;
  12. std::vector<int> result;
  13. for(size_t i = 0 ; i != n ; ++i)
  14. {
  15. char a;
  16. int t;
  17. std::cin>>a>>t;
  18. sum += t;
  19. if(a == '+')
  20. b.push_back(t);
  21. else if (a == '-')
  22. {
  23. for(int i =0 ; i < b.size(); ++i)
  24. {
  25. if(b[i] == t)
  26. b[i] = 0;
  27. }
  28. }
  29. else
  30. {
  31. int cnt = 0;
  32. bool check = false;
  33.  
  34. for(auto c : b)
  35. {
  36. if(t <= c)
  37. {
  38. cnt++;
  39. check = true;
  40. }
  41.  
  42. }
  43. if(check == false && sum> t)
  44. {
  45. cnt++;
  46. }
  47. result.push_back(cnt);
  48. }
  49. for(auto a: result)
  50. cout<<a<<"\n";
  51. }
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement