forked from kbg1910/Codeforces-Round-674-Div.-3-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
que4.txt
93 lines (72 loc) · 1.33 KB
/
que4.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<int , int>
#define int long long int
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define pii 3.14159265358979323
#define inf LLONG_MAX
#define ones(x) __builtin_popcount(x)
#define fill(a,b) memset(a,b,sizeof(a))
#define mod 998244353
ll mod_pow(ll a,ll b,ll m)
{
ll res = 1;
while(b)
{
if(b&1)
{
res=(res*a) % m;
}
a=(a*a) % m;
b>>=1;
}
return res;
}
ll mod_inverse(int a , int m)
{
return mod_pow(a , m - 2 , m);
}
void solve() {
int n;
cin >> n;
int a[n];
map<int , int> f;
for(int i = 0; i < n; ++i) {
cin >> a[i];
}
int pre = 0;
f[0]++;
int last = -1;
int res = 0;
for(int i = 0; i < n; ++i) {
pre += a[i];
if(f.find(pre) != f.end()) {
res++;
last = i - 1;
f.clear();
f[0] = i-1;
pre = a[i];
f[pre] = i;
}
else {
f[pre] = i;
}
}
cout << res << endl;
}
signed main() {
fast;
int t = 1;
//cin >> t;
while(t--) {
solve();
}
return 0;
}