fork(1) download
  1. # include <iostream>
  2. # include <map>
  3. # include <stdlib.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n;
  9. cin >> n;
  10. long long arr[101];
  11. int maxx =0;
  12. int count=0;
  13. map <long long, long long> p;
  14. for(int i=0;i<n;i++)
  15. {
  16. char temp;
  17. cin >> temp;
  18. cin >> arr[i];
  19. if (temp == '-')
  20. arr[i]*=-1;
  21.  
  22. p[abs(arr[i])]+=arr[i];
  23.  
  24. if (arr[i]>0)
  25. count+=1;
  26. else
  27. {
  28. count-=1;
  29. if(p[abs(arr[i])]<0){
  30. maxx+=1;
  31. count+=1;
  32. }
  33. }
  34. if (count > maxx)
  35. maxx=count;
  36.  
  37. }
  38.  
  39.  
  40. cout << maxx;
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 3464KB
stdin
6
+ 12001
- 12001
- 1
- 1200
+ 1
+ 7
stdout
3