// ▓▓▓▓▓▓▓▓▓ ▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
// ▓▓ ▓▓▓ ▓▓▓ ▓▓
// ▓▓▓▓▓▓▓▓ ▓▓▓ ▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓
// ▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓
// ▄▄▄▄▄▄ ▓▓▓▓▓▓▓▓▓ ▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▄▄▄▄▄▄
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
#define ff first
#define ss second
#define cc continue
#define pb push_back
#define ins insert
#define endl cout << endl;
#define all(a) (a).begin(), (a).end()
#define parz(n) [](int x) { for(int i = 2; i * i <= x; ++i) if(x % i == 0) return false; return x > 1; }(n)
#define replr(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define reprl(i, a, b) for (ll i = ll(a); i >= ll(b); --i)
#define rep(i, n) for (ll i = 0; i < ll(n); ++i)
#define mkp(a, b) make_pair(a, b)
#define no {cout << "NO\n";return;}
#define yes {cout << "Alice\n";return;}
template<class T> T mmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T mmin(T& a, T b) {if (a < b) return a; return a = b;}
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> PII;
typedef vector<ll> VI;
typedef vector<bool> VB;
typedef vector<string> VS;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
void solve() {
ll q; cin >> q;
int n; cin >> n;
VL a(n);
set<ll> st;
ll ans = 0;
rep(i,n){
cin >> a[i];
if(a[i] < 0){
st.erase(-a[i]);
}
else {
ll cnt = st.size();
st.ins(a[i]);
if(st.size() == cnt){
ans++;
st.clear();
st.ins(a[i]);
}
}
}
cout << ans;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
ll _ = 1;
// cin >> _;
while (_--)solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |