Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream cin("secv011.in");
- ofstream cout("secv011.out");
- const int nax = 3000005;
- int n;
- int f[nax];
- int main() {
- cin >> n;
- f[n] = 1;
- int pre = 0;
- long long answer = 0;
- for (int i = 1; i <= n; i++) {
- int x;
- cin >> x;
- pre += x;
- answer += f[2 * i - 3 * pre + n];
- f[2 * i - 3 * pre + n]++;
- }
- cout << answer << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment