Submission #198950

# Submission time Handle Problem Language Result Execution time Memory
198950 2020-01-28T09:57:36 Z David Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) Python 3
0 / 100
30 ms 3424 KB
def MOOD(l, r, W2):
    Mood = []
    w = W2[l - 1:r]
    pl = w.copy()
    pl.sort()
    for i in range(0, r + 1 - l):
        if i == pl.index(w[i]):
            continue
        else:
            mood = max(w[i:w.index(pl[i])]) + pl[i]
            w.insert(i, w.pop(w.index(pl[i])))
            Mood.append(mood)
        if max(Mood) is None:
            return 0
        elif Mood:
            return max(Mood)
        else:
            return 0


N, M = random.randint(1, 500), random.randint(1, 500)
W = [random.randint(1, 1000000000) for k in range(N)]
Task = []
for k in range(M):
    r1 = random.randint(1, N)
    l1 = random.randint(1, r1)
    Task.append((l1, r1, random.randint(1, 2000000000)))
for m in range(M):
    if int(MOOD(Task[m][0], Task[m][1], W)) <= Task[m][2]:
        print(1)
    else:
        print(0)
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 3332 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 3332 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 3424 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 3424 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 3332 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 3332 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -