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)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
30 ms |
3332 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
30 ms |
3332 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
29 ms |
3424 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
28 ms |
3424 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
30 ms |
3332 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
30 ms |
3332 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |