Problem:


Entrance Examination

The International Competitive Programming College (ICPC) is famous
for its research on competitive programming.
Applicants to the college are required to take its entrance examination.

The successful applicants of the examination are chosen as follows.

The score of any successful applicant is higher than that of any unsuccessful applicant.

The number of successful applicants n must be between nmin and nmax, inclusive.
We choose n within the specified range that maximizes the gap.
Here, the gap means the difference between the lowest score of
successful applicants and the highest score of unsuccessful applicants.

 When two or more candidates for n make exactly the same gap,
use the greatest n among them.

Let's see the first couple of examples given in Sample Input below.
In the first example, nmin and nmax are two and four, respectively, and there are five applicants whose scores are 100, 90, 82, 70, and 65.
For n of two, three and four, the gaps will be 8, 12, and 5, respectively.
We must choose three as n, because it maximizes the gap.

In the second example, nmin and nmax are two and four, respectively, and there are five applicants whose scores are 100, 90, 80, 75, and 65.
For n of two, three and four, the gap will be 10, 5, and 10, 
respectively. Both two and four maximize the gap, and we must choose the
 greatest number, four.

You are requested to write a program that computes the number of successful applicants that satisfies the conditions.

Input

The input consists of multiple datasets. Each dataset is formatted as follows.

m nmin nmax

P1

P2

...

Pm

The first line of a dataset contains three integers separated by single spaces.
m represents the number of applicants, nmin represents the minimum number of successful applicants, and nmax represents the maximum number of successful applicants.
Each of the following m lines contains an integer
Pi, which represents the score of each applicant.
The scores are listed in descending order.
These numbers satisfy 0 < nmin < nmax < m &#8804; 200, 0 &#8804; Pi &#8804; 10000 (1 &#8804; i &#8804; m) and  Pnmin > Pnmax+1. These ensure that there always exists an n satisfying the conditions.

The end of the input is represented by a line containing three zeros separated by single spaces.

Output

For each dataset, output the number of successful applicants in a line.

Sample Input

5 2 4
100
90
82
70
65
5 2 4
100
90
80
75
65
3 1 2
5000
4000
3000
4 2 3
10000
10000
8000
8000
4 2 3
10000
10000
10000
8000
5 2 3
100
80
68
60
45
0 0 0

Output for the Sample Input

3
4
2
2
3
2



Sample input:
5 2 4
100
90
82
70
65
5 2 4
100
90
80
75
65
3 1 2
5000
4000
3000
4 2 3
10000
10000
8000
8000
4 2 3
10000
10000
10000
8000
5 2 3
100
80
68
60
45
0 0 0


Sample output:
3
4
2
2
3
2

Submission status: Accepted

Solution code:
while True:
    m, n_min, n_max = map(int, input().split())
    if m == 0:
        break
    gap_max = 0
    ans = 0
    pre = int(input())
    for i in range(1, m):
        next = int(input())
        if n_min <= i and n_max >= i:
            tmp = pre - next
            if tmp >= gap_max:
                gap_max = tmp
                ans = i
        pre = next
    print(ans)

Submission status: Accepted

Solution code:
while True:
    m, nMin, nMax = map(int, input().split())
    if m == 0 and nMax == 0 and nMin == 0:
        break
    P = []
    Max = 0
    ans = 0
    for i in range(m):
        P.append(int(input()))
    else:
        for i in range(nMax-nMin+1):
            if i == 0 or Max <= P[nMin+i-1] - P[nMin+i]:
                Max = P[nMin+i-1] - P[nMin+i]
                ans = nMin + i
        else:
            print(ans)

Submission status: Accepted

Solution code:
while 1:
  m, n_min, n_max =map(int, input().split())
  if m==0:
    break
  P =[]
  for p in range(m):
    p =int(input())
    P.append(p)
#    d=[int(input()) for i in range(a)]
#  P.sort()
#  print(P)
  
  gap= 0
  x = 0
  for num in range(n_min, n_max+1):
#    print(num-1)
    a = P[num-1]-P[num]
    if a>=gap:
      gap = a
      x = num
      
#  print(gap)
  print(x)

Submission status: Accepted

Solution code:
while True:
    m,ni,na = map(int,input().split())
    if m+na+ni == 0:
        break
    P = [int(input()) for _ in range(m)]
    P.sort(reverse=True)
    m = 0
    ans = 0
    for i in range(ni-1, na):
        if m <= abs(P[i]-P[i+1]):
            m = abs(P[i]-P[i+1])
            ans = i+1
    print(ans)

Submission status: Accepted

Solution code:

"""
5 2 4
100
90
82
70
65
"""

while True:
    m, nmin, nmax = map(int, input().split())
    if m == 0:
        break
    scores = [int(input()) for _ in range(m)]
    # print(scores)

    dif_score = [scores[0]-scores[1]]
    for i in range(1, m-1):
        dif_score.append(scores[i]-scores[i+1])

    dif_score = dif_score[nmin-1:nmax]

    # print(dif_score)

    max_dif_score = max(dif_score)

    ans = -1
    for i in range(len(dif_score)):
        if dif_score[i] == max_dif_score:
            ans = i

    print(ans+nmin)

Submission status: Accepted

Solution code:
while True:
  m, nmin, nmax = map(int, input().split())
  if m+nmin+nmax == 0:
    break
  P = [int(input()) for i in range(m)]
  gap = 0
  for i in range(nmin, nmax+1):
    if gap<=P[i-1]-P[i]:
      gap = P[i-1]-P[i]  
      n = i
  print(n)

Submission status: Accepted

Solution code:
while True :
  m, n, N = map(int, input().split())
  if(m == 0 and n == 0 and N == 0) :
    break
  else :
    p = [0] * m
    for i in range(m) :
      p[i] = int(input())
    s = 0
    for j in range(n - 1, N) :
      if(p[j] - p[j + 1] >= s) :
        s = p[j] - p[j + 1]
        a = j + 1
      else :
        pass
    print(a)

Submission status: Accepted

Solution code:
# from sys import exit
while(True):
    M, Nmin, Nmax = [int(n) for n in input().split()]
    if M + Nmin + Nmax == 0:
        break
    # N = int(input())
    P = [int(input()) for _ in range(M)]
    # S = str(input())
    # L = len(S)
    # T = str(input())
    # exit()
    dif = [0]*(M)
    for i in range(len(P)-1):
        dif[i+1] = P[i] - P[i+1]
    # print(dif)
    ans = Nmin
    tmp = dif[Nmin]
    for i in range(Nmin+1, Nmax+1):
        if dif[i] >= tmp:
            ans = i
            tmp = dif[i]
    print(ans)

Submission status: Accepted

Solution code:
j = 0
while 1:
    m,n_min,n_max = map(int,input().split())
    if m == 0 and n_max == 0 and n_min == 0:
        break
    lists = []
    ans_list = []
    max = -999999999999
    for i in range(m):
        point = int(input())
        lists.append(point)
    for i in range(n_min-1,n_max):
        num = lists[i] - lists[i+1]
        if max <= num:
            max = num
            ans = i+1
    print(ans)

Submission status: Accepted

Solution code:
def main():
    while True:
        
        head_d = input()
        head_d = head_d.split(" ")
        for i in range(len(head_d)):
            head_d[i] = int(head_d[i])
        if head_d == [0, 0, 0]:
            return

        s_num = head_d[0]
        n_min = head_d[1]
        n_max = head_d[2]
        s_dat = []

        for i in range(s_num):
            s_dat.append(int(input()))

        answer = showpnum(n_min, n_max, s_dat)
        print(answer)


def showpnum(n_min, n_max, s_dat):
    max_dist = 0
    for i in range(n_max - n_min + 1):
        i = i + n_min - 1
        dist = s_dat[i] - s_dat[i + 1]
        if dist >= max_dist:
            max_dist = dist
            pnum = i + 1

    return pnum
    
main()

Submission status: Accepted

Solution code:
def main():
    while True:
        m,minn,maxn = map(int,input().split())
        if m == 0 and minn == 0 and maxn == 0:
            return
        scores = []
        for _ in range(m):
            p = int(input())
            scores.append(p)
        ans,ansgap = 0,0
        for n in range(minn,maxn+1):
            gap = scores[n-1] - scores[n]
            if gap >= ansgap:
                ansgap = gap
                ans = n
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while True:
    n,big,small = map(int,input().split(" "))
    if n == 0:
        break
    points = []
    for i in range(n):
        points.append(int(input()))

    results = []
    for i in range(big,small+1):
        results.append(points[i-1] - points[i])

    ameba = len(results)
    for i in range(ameba):
        if results[ameba-1-i] == max(results):
            print(ameba-i+big-1)
            break

Submission status: Accepted

Solution code:
while 1:
    m, nmin, nmax = map(int, input().split())
    if m == 0:
        break

    score = []
    for _ in range(m):
        score.append(int(input()))
    score.sort(reverse=True)

    ans = 0
    num = 0
    for i in range(nmin, nmax+1):
        gap = score[i-1] - score[i]
        if gap >= ans:
            ans = gap
            num = i

    print(num)

Submission status: Accepted

Solution code:
def main():
    while True:
        m, nmin, nmax = [int(s) for s in input().strip().split(' ')]
        if m == 0:
            break

        plist = sorted((int(input().strip()) for _ in range(m)), reverse=True)
        ni = 0
        gap = 0
        for i in range(nmin-1, nmax):
            ngap = plist[i] - plist[i+1]
            if gap <= ngap:
                gap = ngap
                ni = i
        print(ni+1)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while True:
    num, mini, maxi = map(int, input().split())
    if num == 0: break
    scores = [ int(input()) for i in range(num) ]
    gap = 0
    ans = 0
    for i in range(mini, maxi + 1):
        gap = scores[i-1] - scores[i] if scores[i-1] - scores[i] >= gap else gap
        ans = i if scores[i - 1] - scores[i] >= gap else ans

    print(ans)

Submission status: Accepted

Solution code:
while 1:
    m,a,b = map(int, input().split())
    if m==0: break
    p = [int(input()) for i in range(m)]
    key = 0
    ans = 2
    for i in range(a,b+1):
        v = p[i-1]-p[i]
        if v >= key:
            ans = i
            key = v
    print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
while 1:
    m,n_min,n_max=map(int,input().split())
    if m==0:
        break
    data=[]
    for i in range(m):
        data.append(int(input()))
    data=sorted(data,reverse=True)
    mx=(-1,-1)
    for i in range(n_min,n_max+1):
        if data[i-1]-data[i]>=mx[0]:
            mx=(data[i-1]-data[i],i)
    print(mx[1])

Submission status: Runtime Error

Solution code:
N = input().split(" ")
a = [input() for i in range(int(N[0]))]
ma =int(N[2])
mi =int(N[1])
gap = []
x = mi
while x != ma + 1:
   value = int(a[x - 1]) - int(a[x])
   gap.append(value)
   x = x + 1
import numpy as np
gapIndex = np.array(gap)
maxIndex = [i for i, x in enumerate(gapIndex) if x == max(gapIndex)]
print(int(maxIndex[0]) + 2)

Submission status: Runtime Error

Solution code:
import numpy as np
while true:
    N = input().split(" ")
    if N[0] == 0:
        break
    a = [input() for i in range(int(N[0]))]
    print(N)
    print(a)
    #b = int(a[int(N[1]) - 1]) - int(a[int(N[1])])
    #print(b)
    ma = int(N[2])
    mi = int(N[1])
    gap = []
    x = mi
    while x != ma + 1:
        value = int(a[x - 1]) - int(a[x])
        gap.append(value)
        x = x + 1
    #print(gap)
    gapIndex = np.array(gap)
    maxIndex = [i for i, x in enumerate(gapIndex) if x == max(gapIndex)]
    print(int(maxIndex[0]) + 2)

Submission status: Runtime Error

Solution code:
head = input().split(" ")
while head != "0 0 0":
    num = int(head[0])
    mini = int(head[1])
    maxi = int(head[2]) 

    scores = []

    gaps = []

    for i in range(int(head[0])):
        scores.append(int(input()))
    
    for i in range(mini, maxi):
        oks = scores[:i]
        ngs = scores[i:]
        gap = oks[-1] - ngs[0]
        gaps.append((i,gap))

    filtered = list(filter(lambda x: x[1] == max(gaps), gaps))
    sorted(filtered, lambda x: x[0], True)
    print(filtered[0][0])

Submission status: Runtime Error

Solution code:
head = input().split(" ")
while head != "0 0 0":
    num = int(head[0])
    mini = int(head[1])
    maxi = int(head[2]) 

    scores = []

    gaps = []

    for _ in range(int(head[0])):
        scores.append(int(input()))
    
    for i in range(mini, maxi + 1):
        oks = scores[:i]
        ngs = scores[i:]
        gap = oks[-1] - ngs[0]
        gaps.append((i,gap))

    filtered = list(filter(lambda x: x[1] == max(map(lambda x: x[1], gaps)), gaps))
    sorted(filtered,key=lambda x: x[0])
    print(filtered[-1][0])

Submission status: Runtime Error

Solution code:
head = input().split(" ")
while head != "0 0 0":
    num = int(head[0])
    mini = int(head[1])
    maxi = int(head[2]) 

    scores = []

    gaps = []

    for _ in range(int(head[0]) + 1):
        scores.append(int(input()))
    
    for i in range(mini, maxi + 1):
        oks = scores[:i]
        ngs = scores[i:]
        gap = oks[-1] - ngs[0]
        gaps.append((i,gap))

    filtered = list(filter(lambda x: x[1] == max(map(lambda x: x[1], gaps)), gaps))
    sorted(filtered,key=lambda x: x[0])
    print(filtered[-1][0])

Submission status: Runtime Error

Solution code:
answers = []
while True:
    head = input()
    if head == "0 0 0":
        break
    nums = head.split(" ")
    num = int(head[0])
    mini = int(head[1])
    maxi = int(head[2]) 

    scores = []

    gaps = []

    for _ in range(int(head[0])):
        scores.append(int(input()))
    
    for i in range(mini, maxi + 1):
        oks = scores[:i]
        ngs = scores[i:]
        gap = oks[-1] - ngs[0]
        gaps.append((i,gap))

    filtered = list(filter(lambda x: x[1] == max(map(lambda x: x[1], gaps)), gaps))
    sorted(filtered,key=lambda x: x[0])
    answers.append(filtered[-1][0])

for i in answers:
    print(i)

Submission status: Runtime Error

Solution code:
answers = []
while True:
    head = input()
    if head == "0 0 0":
        break
    nums = head.split(" ")
    num = int(nums[0])
    mini = int(nums[1])
    maxi = int(nums[2]) 

    scores = []

    gaps = []

    for _ in range(int(head[0])):
        scores.append(int(input()))
    
    for i in range(mini, maxi + 1):
        oks = scores[:i]
        ngs = scores[i:]
        gap = oks[-1] - ngs[0]
        gaps.append((i,gap))

    filtered = list(filter(lambda x: x[1] == max(map(lambda x: x[1], gaps)), gaps))
    sorted(filtered,key=lambda x: x[0])
    answers.append(filtered[-1][0])

for i in answers:
    print(i)

Submission status: Runtime Error

Solution code:
answers = []
while True:
    head = input()
    if head == "0 0 0":
        break
    nums = head.split(" ")
    num = int(nums[0])
    mini = int(nums[1])
    maxi = int(nums[2]) 

    scores = []

    gaps = []

    for _ in range(int(head[0])):
        scores.append(int(input()))
    
    for i in range(mini, maxi + 1):
        oks = scores[:i]
        ngs = scores[i:]
        if len(oks) and len(ngs): 
            gap = oks[-1] - ngs[0]
            gaps.append((i,gap))

    filtered = list(filter(lambda x: x[1] == max(map(lambda x: x[1], gaps)), gaps))
    sorted(filtered,key=lambda x: x[0])
    answers.append(filtered[-1][0])

for i in answers:
    print(i)