Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- #include <list>
- using namespace std;
- int main()
- {
- size_t n;
- cin>>n;
- std::vector<int> b;
- int sum = 0;
- std::vector<int> result;
- for(size_t i = 0 ; i != n ; ++i)
- {
- char a;
- int t;
- std::cin>>a>>t;
- sum += t;
- if(a == '+')
- b.push_back(t);
- else if (a == '-')
- {
- for(int i =0 ; i < b.size(); ++i)
- {
- if(b[i] == t)
- b[i] = 0;
- }
- }
- else
- {
- int cnt = 0;
- bool check = false;
- for(auto c : b)
- {
- if(t <= c)
- {
- cnt++;
- check = true;
- }
- }
- if(check == false && sum> t)
- {
- cnt++;
- }
- result.push_back(cnt);
- }
- for(auto a: result)
- cout<<a<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement