fork download
  1. #include <stdio.h>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. #define N_MAX 100000
  6.  
  7. int N, vetor[N_MAX], vetor2[N_MAX],i;
  8.  
  9. int main (){
  10. cin>>N;
  11. for (i = 0; i < N; i++)
  12. cin>>vetor[i];
  13.  
  14. vetor2[0] = vetor[0];
  15. for (i = 1; i < N; i++)
  16. vetor2[i] = vetor2[i - 1] + vetor[i];
  17.  
  18. for (i = 0; i < N; i++)
  19. if (vetor2[i] == vetor2[N - 1] - vetor2[i])
  20. break;
  21.  
  22. cout<<i + 1<<endl;
  23. return 0;
  24. }
Success #stdin #stdout 0s 16840KB
stdin
4
5 3 2 10
	
stdout
3