File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Codeforces_Contests/7_Round_674_Div_3 Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ #define int long long
5
+ #define ll long long
6
+ #define pb push_back
7
+ #define mp make_pair
8
+ #define f (i,a,n ) for (int i=a ; i<n ; i++)
9
+ #define rf (i,n,a ) for (int i=n ; i>=a ; i--)
10
+ #define F first
11
+ #define S second
12
+ #define all (c ) (c).begin(),(c).end()
13
+ #define sz (v ) (int )(v).size()
14
+ #define fast ios::sync_with_stdio (0 ); cin.tie(0 ); cout.tie(0 )
15
+
16
+ typedef long double ld;
17
+ typedef vector<int > vi;
18
+ typedef pair<int ,int > pii;
19
+ typedef pair<pii,int > ppi;
20
+ typedef vector<pii> vpi;
21
+
22
+ const int inf = 1e9 ;
23
+ const int inf64 = 1e18 ;
24
+ const int MOD = inf + 7 ;
25
+
26
+
27
+ void solve (){
28
+ int n;
29
+ cin >> n;
30
+
31
+ int a[n];
32
+ f (i,0 ,n) cin >> a[i];
33
+
34
+ set<int >s;
35
+ s.insert (0 );
36
+
37
+ int ans = 0 , sum = 0 ;
38
+ f (i,0 ,n){
39
+ sum += a[i];
40
+ if (s.find (sum) != s.end ()){
41
+ s.clear ();
42
+ ans++;
43
+ sum = a[i];
44
+ s.insert (0 );
45
+ }
46
+ s.insert (sum);
47
+ }
48
+ cout << ans << " \n " ;
49
+ }
50
+
51
+ int32_t main (){
52
+ fast;
53
+ int t = 1 ;
54
+ // cin >> t;
55
+ while (t--) solve ();
56
+ }
You can’t perform that action at this time.
0 commit comments