fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define LLI long long int
  4. #define LD long double
  5. #define PB push_back
  6. #define MP make_pair
  7. #define FORi(i, a, b) for(int i = a; i < b ; ++i)
  8. #define FORd(i, a, b) for(int i = a; i > b ; --i)
  9.  
  10. using namespace std;
  11.  
  12. const int mod = 1e9 + 7;
  13.  
  14. struct comp{
  15. bool operator()(pair<int,char>& a, pair<int,char>& b){
  16. if (a.first == b.first){
  17. if (a.second == '+')
  18. return 1;
  19. else
  20. return a==b;
  21. }
  22. return a.first < b.first;
  23. }
  24. };
  25.  
  26. int main() {
  27. int n, ans=1;
  28. cin >> n;
  29. vector<pair<int,char> > v(n);
  30. FORi(i,0,n){
  31. cin >> v[i].first >> v[i].second;
  32. }
  33. sort(v.begin(), v.end(), comp());
  34. bool is_neg = 0;
  35. FORi(i,0,n){
  36. if (is_neg && v[i].second == '+'){
  37. ans++;
  38. break;
  39. }
  40. if (!is_neg && v[i].second == '-'){
  41. is_neg = 1;
  42. }
  43. }
  44. cout << ans;
  45. return 0;
  46. }
Success #stdin #stdout 0s 3464KB
stdin
3
2 +
5 -
0 +
stdout
1