Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemoryError i python kan ta ned serveren #15

Open
aasmundeldhuset opened this issue Mar 24, 2012 · 1 comment
Open

MemoryError i python kan ta ned serveren #15

aasmundeldhuset opened this issue Mar 24, 2012 · 1 comment

Comments

@aasmundeldhuset
Copy link

Bruk av f.eks. range() i stedet for xrange() kan medføre MemoryError. På datasett 9 i oppgave 2 i finalen krasjer dette serveren (ikke bare webappen, men hele operativsystemet - usikker på om dette er vår eller Windows sin feil).

@aasmundeldhuset
Copy link
Author

inn1 = raw_input().split(' ')
n=int(inn1[0])
m=int(inn1[1])
h =list()
nds = list()

for i in range(m):
    h.append(int(raw_input()))

mx=h[-1]
def find_dist(nd):
    dist = list()
    l=list()
    for i in h:
        dist.append(list())
        for u in nd:
            dist[-1].append(abs(i-u))
        dist[-1].sort()
    for u in dist:
        l.append(u[0])
    return l

for n1 in range(h[-1]):
    for n2 in range(h[-1]):
        nds = [n1,n2]
        mx_lst = find_dist(nds)
        mx_lst.sort()
        if mx_lst[-1] < mx:
            mx = mx_lst[-1]
print mx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant