Last active
May 6, 2020 03:54
-
-
Save Thiago4532/2de37125a70b1bed4516b2d5a8d4c4ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| const int maxn = 2e5 + 10; | |
| int n; | |
| map<long long, int> freq; | |
| int32_t main() { | |
| cin >> n; | |
| long long s=0; | |
| int ans = n - 1; | |
| for(int i=1;i<=n;i++) { | |
| int x; | |
| cin >> x; | |
| s += x; | |
| freq[s]++; | |
| ans = min(ans, n - freq[s]); | |
| } | |
| cout << ans << "\n"; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment