def MOOD(l, r, W1):
Mood = []
w = W1[l - 1:r]
pl = w.copy()
pl.sort()
mood = 0
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)
return max(Mood)
nm = input().split(' ')
N, M = int(nm[0]), int(nm[1])
W = input().split(' ')
Task = []
for i in range(M):
Task.append(input().split(' '))
for i in range(M):
if MOOD(int(Task[i][0]), int(Task[i][1]), W) <= int(Task[i][2]):
print(1)
else:
print(0)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
30 ms |
3344 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
30 ms |
3344 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3388 ms |
238528 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
388 ms |
45332 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
30 ms |
3344 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
30 ms |
3344 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |