#30639: 請問為什麼 會在第一筆測資時 發生 SE


u11031107 (立波器)


def RMQ(l,r):
  global Sorted
  while Sorted[-1]>r or Sorted[-1]<l:
     Sorted.pop()
  return Sorted[-1]
n=int(input())
p=list(map(int,input().split()))#3*10**5 nlogn
inf=[]
pre_sum=[0]
the=0
for 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)-1
left=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-1
  else:
    left=index+1

 

  #pre=pre_sum[index-1]
  #last=pre_sum[right]
  #index=0
  #print(index)
#print(right)
print(p[right])
 
 
 
請問為什麼 會在第一筆測資時 發生 SE
#30655: Re: 請問為什麼 會在第一筆測資時 發生 SE


cges30901 (cges30901)


def RMQ(l,r):
  global Sorted
  while Sorted[-1]>r or Sorted[-1]
     Sorted.pop()
  return Sorted[-1]
n=int(input())
p=list(map(int,input().split()))#3*10**5 nlogn
inf=[]
pre_sum=[0]
the=0
for 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)-1
left=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-1
  else:
    left=index+1

 

  #pre=pre_sum[index-1]
  #last=pre_sum[right]
  #index=0
  #print(index)
#print(right)
print(p[right])
 
 
 
請問為什麼 會在第一筆測資時 發生 SE


我用你的程式碼直接送出可以AC

#30661: Re: 請問為什麼 會在第一筆測資時 發生 SE


r1cky (hehe)


def RMQ(l,r):
  global Sorted
  while Sorted[-1]>r or Sorted[-1]
     Sorted.pop()
  return Sorted[-1]
n=int(input())
p=list(map(int,input().split()))#3*10**5 nlogn
inf=[]
pre_sum=[0]
the=0
for 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)-1
left=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-1
  else:
    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就只是因為系統故障?

#30664: Re: 請問為什麼 會在第一筆測資時 發生 SE


fire5386 (becaidorz)


 


SE 應該是指系統出了問題吧,的確6/1的時候ZJ怪怪的,如果你是那時候提交拿SE就只是因為系統故障?


瑞1奇電電電把系統電壞了