Why do i have RUNTIME_ERROR 722C???

Revision en3, by CF2_kafuma, 2016-10-16 08:33:49

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 ])));
Tags dsu, python 2

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English CF2_kafuma 2016-10-16 08:33:49 1190
en2 English CF2_kafuma 2016-10-15 21:52:03 22
en1 English CF2_kafuma 2016-10-15 21:50:22 1556 Initial revision (published)