Advertisement
Dennnhhhickk

Untitled

Jan 26th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5. struct tt{
  6. int l, r;
  7. };
  8.  
  9. int main()
  10. {
  11. int n, i, j, z;
  12. long long sum = 0, ans = 0;
  13. cin >> n;
  14. vector <int> a(n);
  15. for ( i = 0; i < n; i++)
  16. cin >> a[i];
  17. for ( i = 0; i < n; i++){
  18. sum = a[i];
  19. j = i + 1;
  20. z = 1;
  21. while (sum > 0 && z <= n){
  22. sum += a[j];
  23. z++;
  24. j = (j + 1) % n;
  25. //cout << a[i] << " " << sum << endl;
  26. }
  27. if (!(z == n && sum < 0) && !(z < n)){
  28. ans++;
  29. //cout << i << endl;
  30. }
  31. }
  32. cout << ans << endl;
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement