AlexNeagu11

Untitled

Feb 23rd, 2024
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. ifstream cin("secv011.in");
  5. ofstream cout("secv011.out");
  6.  
  7. const int nax = 3000005;
  8.  
  9. int n;
  10. int f[nax];
  11.  
  12. int main() {
  13. cin >> n;
  14. f[n] = 1;
  15. int pre = 0;
  16.  
  17. long long answer = 0;
  18. for (int i = 1; i <= n; i++) {
  19. int x;
  20. cin >> x;
  21. pre += x;
  22. answer += f[2 * i - 3 * pre + n];
  23. f[2 * i - 3 * pre + n]++;
  24. }
  25.  
  26. cout << answer << '\n';
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment