P8939 python3 RE求助
  • 板块题目总版
  • 楼主wangxs0
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/12/20 11:19
  • 上次更新2023/12/20 16:45:15
查看原帖
P8939 python3 RE求助
613417
wangxs0楼主2023/12/20 11:19

求助,这段代码为什么会RE,想不明白

import sys
input = sys.stdin.readline
from sortedcontainers import SortedList

n, q = map(int, input().split())
a = list(map(int, input().split()))
st = SortedList(a)

for _ in range(q):
    opt, x = map(int, input().split())
    if opt == 1:
        if st.count(x):
            st.remove(x)
        else:
            print(-1)
            continue
    else:
        st.add(x)
    print(2*(st[-1]-st[0]))
2023/12/20 11:19
加载中...