Home > other >  Blue bridge exercise - 1 cup algorithm for help
Blue bridge exercise - 1 cup algorithm for help

Time:03-23

Blue cup algorithm practice 1
Problem description
Given a sequence, each time you ask the l number to the r in the sequence number of which is the first large number K,

Find the answer on the Internet is such a
 n=int (input ()) 
Number_list=list (map (int, input (). The split ()))
M=int (input ())
Tar_list=[]
For I in range (m) :
L, r, k=list (map (int, input (). The split ()))
Tar_list. Append (sorted (number_list [l - 1: r], reverse=True)] [k - 1)
For I in range (m) :
Print (tar_list [I])


My answer is initially such
 n=int (input ()) 
Ls=list (map (int, input (). The split (' ')))
M=int (input ())
Ans=[]

For I in range (m) :
L, r, K=list (map (int, input (). The split ()))
LST=[]
For j in range (l - 1, r) :
LST. Append (ls) [j]
LST. Sort (reverse=True)
Ans. Append (LST) [K - 1]
For I in range (m) :
Print (ans) [I]


Later changed to this
 n=int (input ()) 
Ls=list (map (int, input (). The split (' ')))
M=int (input ())
Ans=[]
LST=[]

For I in range (m) :
L, r, K=list (map (int, input (). The split ()))
LST. Append (sorted (ls [l - 1: r], reverse=True))
Ans. Append (LST [I]] [K - 1)
For I in range (m) :
Print (ans) [I]


In the system, the operation of memory and time are not more than, but my code to run is show operation error, test the sample no problem, also download output are compared with those of the first output of the code, and there is no difference, so I don't know what my code where there is a problem, which members can help have a look at ah!!!!!! Thank ~ ~ ~
  • Related