def RMQ(l,r):global Sortedwhile Sorted[-1]>r or Sorted[-1]Sorted.pop()return Sorted[-1]n=int(input())p=list(map(int,input().split()))#3*10**5 nlogninf=[]pre_sum=[0]the=0for i in range(len(p)):the+=p[i]pre_sum.append(the)inf.append([p[i],i])Sorted=[]inf.sort(key=lambda x:x[0],reverse=True)for i in inf:Sorted.append(i[1])#print(pre_sum)right=len(inf)-1left=0#print(inf)#print(pre_sum)while right!=left:#print(left," ",right)index=RMQ(left,right)#print(index)pre=pre_sum[index]-pre_sum[left]last=pre_sum[right+1]-pre_sum[index+1]#print(pre," ",last)if pre>last:right=index-1else:left=index+1
#pre=pre_sum[index-1]#last=pre_sum[right]#index=0#print(index)#print(right)print(p[right])請問為什麼 會在第一筆測資時 發生 SE
我用你的程式碼直接送出可以AC
def RMQ(l,r):global Sortedwhile Sorted[-1]>r or Sorted[-1]Sorted.pop()return Sorted[-1]n=int(input())p=list(map(int,input().split()))#3*10**5 nlogninf=[]pre_sum=[0]the=0for i in range(len(p)):the+=p[i]pre_sum.append(the)inf.append([p[i],i])Sorted=[]inf.sort(key=lambda x:x[0],reverse=True)for i in inf:Sorted.append(i[1])#print(pre_sum)right=len(inf)-1left=0#print(inf)#print(pre_sum)while right!=left:#print(left," ",right)index=RMQ(left,right)#print(index)pre=pre_sum[index]-pre_sum[left]last=pre_sum[right+1]-pre_sum[index+1]#print(pre," ",last)if pre>last:right=index-1else:left=index+1
#pre=pre_sum[index-1]#last=pre_sum[right]#index=0#print(index)#print(right)print(p[right])請問為什麼 會在第一筆測資時 發生 SE
SE 應該是指系統出了問題吧,的確6/1的時候ZJ怪怪的,如果你是那時候提交拿SE就只是因為系統故障?