def MOOD(l, r, W2):
Mood = []
w = W2[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])
W1 = input().split(' ')
W = [int(k) for k in W1]
Task = []
for k in range(M):
Task.append(input().split(' '))
for m in range(M):
if int(MOOD(int(Task[m][0]), int(Task[m][1]), W)) <= int(Task[m][2]):
print(1)
else:
print(0)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
3300 KB |
Output is correct |
2 |
Runtime error |
29 ms |
3340 KB |
Execution failed because the return code was nonzero |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
3300 KB |
Output is correct |
2 |
Runtime error |
29 ms |
3340 KB |
Execution failed because the return code was nonzero |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3115 ms |
260072 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
423 ms |
46580 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
3300 KB |
Output is correct |
2 |
Runtime error |
29 ms |
3340 KB |
Execution failed because the return code was nonzero |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
3300 KB |
Output is correct |
2 |
Runtime error |
29 ms |
3340 KB |
Execution failed because the return code was nonzero |
3 |
Halted |
0 ms |
0 KB |
- |