### CF2_kafuma's blog

By CF2_kafuma, history, 4 years ago,

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];
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):
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 ])));


• -2

 » 4 years ago, # |   0 Auto comment: topic has been updated by CF2_kafuma (previous revision, new revision, compare).