that's my code , and i can't understand why i have RUNTime_Error?? can someone explain me??
Limite = input();
Valores = map(int, raw_input().split());
Permutacion = map(lambda x: int(x) - 1, raw_input().split());
Rpta = [0];
Visitado = [False]*Limite;
DSU = range(Limite);
DSUValor = [0]*Limite;
def Find(posicion):
if posicion != DSU[posicion]:
DSU[posicion] = Find(DSU[posicion]);
return DSU[posicion];
def Union(A, B):
Pos_A = Find(A);
Pos_B = Find(B);
DSU[Pos_B] = Pos_A;
DSUValor[Pos_A] += DSUValor[Pos_B];
for x in reversed(Permutacion):
Visitado[x] = True;
DSUValor[ x ] = Valores[ x ];
if x - 1 >= 0 and Visitado[x - 1]:
Union(x, x - 1);
#Valores[ x ] += Valores[ Find( x -1 ) ];
#DSU[ Find( x - 1 ) ] = x;
if x + 1 < Limite and Visitado[x + 1]:
Union(x, x + 1);
#Valores[x] += Valores[Find(x + 1)];
#DSU[Find(x + 1)] = x;
#DSUValor[x] += Valores[x];
Rpta.append(max( Rpta[-1], DSUValor[x]));
print '\n'.join(map(str, reversed(Rpta[:-1 ])));