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: Wrong Answer

Solution code:
import sys
while True:
    m, nmin, nmax = [int(i) for i in input().split()]
    if m == 0:
        sys.exit()
    p = [int(input()) for i in range(m)]
    ansnum = 1000000
    ans = 0
    for i in range(nmin-1,nmax):
        if ansnum >= p[i]-p[i+1]:
            ans = i
        ansnum = min(ansnum,p[i]-p[i+1])
    print(ans)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python
#-*- coding: utf-8 -*-

while True:
    (m, nmin, nmax) = map(int, raw_input().split())
    if m == 0:
        break

    scores = []
    for i in range(m):
        scores.append(int(raw_input()))
    
    submax = 0
    for i in range(nmin, nmax):
        subtmp = scores[i-1] - scores[i]
        if subtmp > submax:
            ans = i
            submax = subtmp

    print ans

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python
#-*- coding: utf-8 -*-

while True:
    (m, nmin, nmax) = map(int, raw_input().split())
    if m == 0:
        break

    scores = []
    for i in range(m):
        scores.append(int(raw_input()))
    
    submax = 0
    for i in range(nmin, nmax):
        subtmp = scores[i-1] - scores[i]
        if subtmp >= submax:
            ans = i
            submax = subtmp

    print ans

Submission status: Wrong Answer

Solution code:
while 1:
    m,nn,nx= map(int,input().split())
    if m==0: break
    s=[int(input()) for _ in range(m)]
    v=k=0
    for i in range(nn-1,nx):
        t=s[i]-s[i+1]
        if v<t:
            k,v=i+1,t
    print(k)

Submission status: Wrong Answer

Solution code:
while True:
    P = list()
    ans = list()
    tans = list()
    m, Mn, Mx = map(int, input().split())
    if m == 0 and Mn == 0 and Mx == 0:
        break
    for i in range(0, m):
        P.append(int(input()))

    for j in range(Mn-1, Mx, 1):
        ans.append(P[j]-P[j+1])
    print(ans)
    for k in range(0,len(ans)):
        if ans[k] == max(ans):
            tans.append(k)
    print(tans)
    print(max(tans)+Mn)

Submission status: Wrong Answer

Solution code:
da = list(map(int,input().split()))
k = []
while sum(da) != 0:
	for i in range(da[0]):
		k.append(int(input()))
	for i in range(da[0]):
		k[da[0] - 1 -i] = k[da[0] - 1 -i] - k[da[0]-2 -i]


	pp = k[da[1]:da[2]+1]
	print(pp)
	qq = min(pp)

	for i in range(len(pp)):
		if pp[i] == qq:
			jj = i

	print(da[1]+jj)

	da = list(map(int,input().split()))
	k = []

Submission status: Wrong Answer

Solution code:
while True:
    (m, mn, mx) = tuple(map(int, input().split()))
    if m == 0:
        break
    arr = [0 for i in range(m)]
    for i in range(m):
        arr[i] = int(input())
    arr.sort(reverse=True)
    res = []
    ap = res.append
    for i in range(mn, mx + 1):
        ap([arr[i - 1] - arr[i], i])
    res.sort(key=lambda x: 10 * x[0] + x[1], reverse=True)
    print(res[0][1])

Submission status: Wrong Answer

Solution code:
while 1:
    m,nmi,nma=map(int,input().split())
    if not m and not nmi and not nma:break
    l=[int(input()) for _ in range(m)]
    tg=[l[:i][-1]-l[i:][0] for i in range(nmi,nma+1)]
    print(tg.index(max(tg))+nmi)

Submission status: Accepted

Solution code:
# AOJ 1600 Entrance Examination
# Python3 2018.7.13 bal4u

while True:
	m, nmin, nmax = map(int, input().split())
	if m == 0: break
	p = [int(input()) for i in range(m)]
	gap = 0
	for i in range(nmax-1, nmin-2, -1):
		d = p[i]-p[i+1]
		if d > gap: gap, ans = d, i
	print(ans+1)

Submission status: Accepted

Solution code:
anslist = []

while True:
    m, nmin, mmax = map(int, input().split())
    if m == 0 and nmin == 0 and mmax == 0:
        break
    p = [int(input()) for i in range(m)]
    p.sort()

    ans = 0
    line = 0
    for i in range(m - mmax, m - nmin + 1):
        if ans < p[i] - p[i - 1]:
            ans = p[i] - p[i - 1]
            line = i
    #print(line)
    anslist.append(m - line)

for i in anslist:
    print(i)

Submission status: Accepted

Solution code:
while True:
    m, n_min, n_max = map(int, input().split())
    if m == 0 and n_min == 0 and n_max == 0:
        break
    P = [int(input()) for _ in range(m)]
    ans = [0, 0]
    for i in range(n_min, n_max+1):
        # print("i: {}, P[i-1]: {}, P[i]: {}".format(i, P[i-1], P[i]))
        ans[0] = max(P[i - 1] - P[i], ans[0])
        if ans[0] == P[i - 1] - P[i]:
            ans[1] = i
    print(ans[1])

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

while True:
    m,nmin,nmax = inpl()
    if m == 0:
        break
    else:
        pp = [int(input()) for _ in range(m)]
        pp.sort(reverse=True)
        ans = 0
        ansgap = -1
        for n in range(nmin,nmax+1):
            gap = pp[n-1] - pp[n]
            if ansgap <= gap:
                ansgap = gap
                ans = n

        print(ans)

Submission status: Accepted

Solution code:
#1600_入学試験
#1行目：（m, nmin, nmax) [(データ個数, 合格者最小人数, 合格者最大人数)]
#合格者数 n は nmin 人以上，nmax 人以下とする． n はこの範囲内でギャップを最大とするものでなくてはいけない． 
#ギャップとは合格者の最低点と不合格者の最高点の差
#同じギャップになる n が複数あるときは，その中で n が最大になるように選ぶ．


while True :

  m, nmin, nmax = map(int,input().split())
  #もしm=0ならbreak
  if m == 0:
    break
  else:
    #配列n[i]を読み込む(1<=i<=n)
    n = [int(input()) for i in range(m)]
    
    gap = 0
    cnt = 0
    
    for i in range(nmax, nmin-1,-1) :
      #iのときのギャップを求める
      if (abs(n[i]- n[i-1])) > gap :
        
        gap =  abs(n[i] - n[i-1])
        cnt = i
        
        
        
    
    print(cnt)

Submission status: Accepted

Solution code:
import sys
anslist = []
while True:
    m, nmin, nmax = [int(i) for i in input().split()]
    if m == 0:
        for i in anslist:
            print(i)
        sys.exit()
    p = [int(input()) for i in range(m)]
    ansnum = 0
    ans = 0
    for i in range(nmin-1,nmax):
        if ansnum <= p[i]-p[i+1] and not p[i]-p[i+1]==0:
            ans = i
            ansnum = p[i]-p[i+1]
    anslist.append(ans+1)

Submission status: Accepted

Solution code:
while True:
    m,nMin,nMax=map(int,raw_input().split())
    if m==0: break
    p=[]
    for _ in xrange(m):
        p.append(int(raw_input()))
    maxN=0
    maxD=0
    for i in xrange(nMin-1,nMax):
        if maxD <= p[i]-p[i+1]:
            maxD = p[i]-p[i+1]
            maxN = i+1
    print maxN

Submission status: Accepted

Solution code:
while True:
    m,mn,mx = map(int,input().split())
    if m==0: break
    l = [int(input()) for _ in range(m)]
    r = []
    for i in range(mn,mx+1):
        r += [l[i-1]-l[i]]
    print(max([i+mn for i,x in enumerate(r) if x==max(r)]))

Submission status: Accepted

Solution code:
while True:
    m,mn,mx = map(int,raw_input().split())
    if m==0: break
    l = [int(input()) for _ in range(m)]
    r = []
    for i in range(mn,mx+1):
        r += [l[i-1]-l[i]]
    print max([i+mn for i,x in enumerate(r) if x==max(r)])

Submission status: Accepted

Solution code:
while True:
    sa_max = 0
    Sa = []
    num = 0
    Poi_lis = []
    m,nmin,nmax = map(int,input().split())
    if [m,nmin,nmax] == [0,0,0]:
        break
    for i in range(m):
        Poi_lis.append(int(input()))
        if nmin + 1 <= i + 1 <= nmax + 1:
            Sa.append(Poi_lis[i - 1] - Poi_lis[i])
    Sa_r = Sa[::-1]
    
    cou = Sa_r.index(max(Sa_r))
    print(nmin + len(Sa) - cou - 1)

Submission status: Accepted

Solution code:
while 1:
    m, n1, n2 = map(int, raw_input().split())
    if m==0:
        break
    P = [int(raw_input()) for i in xrange(m)]
    P.sort()
    m = 0
    idx = -1
    for i in xrange(n2, n1-1, -1):
        v = P[-i] - P[-i-1]
        if m < v:
            m = v
            idx = i
    print idx

Submission status: Accepted

Solution code:
#!usr/bin/env python
#-*- coding: utf-8 -*-

while True:
    (m, nmin, nmax) = map(int, raw_input().split())
    if m == 0:
        break

    scores = []
    for i in range(m):
        scores.append(int(raw_input()))
    
    submax = 0
    for i in range(nmin, nmax+1):
        subtmp = scores[i-1] - scores[i]
        if subtmp >= submax:
            ans = i
            submax = subtmp

    print ans

Submission status: Accepted

Solution code:
while 1:
    a,b,c=map(int,input().split())
    if a==0:break
    d=[int(input()) for i in range(a)]
    e=0
    for i in range(b,c+1):
        if d[i-1]-d[i]>=e:
            e=d[i-1]-d[i]
            f=i
    print(f)

Submission status: Accepted

Solution code:
while 1:
    m,nn,nx= map(int,input().split())
    if m==0: break
    s=[int(input()) for _ in range(m)]
    v=k=0
    for i in range(nn-1,nx):
        t=s[i]-s[i+1]
        if v<=t:
            k,v=i+1,t
    print(k)

Submission status: Accepted

Solution code:
while True:
    m, n_min, n_max = map(int, input().split())
    if m == n_min == n_max == 0:
        break
    prev = int(input())
    diff = [0] * m
    mx = 0

    for i in range(1, m):
        now = int(input())
        diff[i] = prev - now
        prev = now

    ans = 0
    for i in range(n_min, n_max + 1):
        if mx <= diff[i]:
            ans = i
            mx = diff[i]

    print(ans)

Submission status: Accepted

Solution code:

def solver():
    m, nmin, nmax = map(int, input().split())
    if m == 0 and nmin == 0 and nmax == 0:
        return None
    p = [int(input()) for _ in range(m)]
    ans = 0
    maxdelta = 0
    for a in range(nmin, nmax+1):
        delta = p[a-1] - p[a]
        if delta >= maxdelta:
            maxdelta = delta
            ans = a
    return ans

outputs = []
while True:
    ans = solver()
    if ans == None:
        break
    outputs.append(ans)
print('\n'.join(map(str, outputs)))

Submission status: Accepted

Solution code:
def solve():
    m, mn, mx = map(int, input().split())
    if m == 0 and mn == 0 and mx == 0:
        return False

    p = [int(input()) for x in range(m)]

    result, ans = 0, 0

    for i in range(mn, mx + 1):
        if p[i - 1] - p[i] >= result:
            result = p[i - 1] - p[i]
            ans = i
    print(ans)
    return True

while solve(): pass

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    while 1:
        m,nmin,nmax = list(map(int,input().strip().split()))
        if m == nmin == nmax ==0:break
        points = []
        for _ in range(m):points.append(int(input()))
        ans = 0
        diff = 0
        for i in range(nmin,nmax+1):
            if diff < points[i-1] - points[i]:
                ans = i
                diff = points[i-1] - points[i]
            elif diff == points[i-1] -points[i] and i > ans :ans =i
        print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
while True:
    M,NMIN,NMAX = map(int,input().split())
    if M == 0: break
    src = [int(input()) for i in range(M)]
    ctr = Counter(src)
    ctr = list(ctr.items())
    ctr.sort(reverse=True)
    
    n = passed = maxgap = 0
    for (s1,n1),(s2,n2) in zip(ctr, ctr[1:]):
        n += n1
        if n < NMIN: continue
        if n > NMAX: break
        gap = s1-s2
        if gap >= maxgap:
            maxgap = gap
            passed = n
    print(passed)

Submission status: Accepted

Solution code:
#!/usr/bin/python

while True:
	m,a,b = map(int, raw_input().split(' '))
	if m == 0:
		break
	P = [int(raw_input()) for i in range(0,m)]
	x,ans = -1,0
	for i in range(a,b+1):
		sub = P[i-1] - P[i]
		if x < sub:
			x = sub
		if x == sub:
			ans = i
	print ans

Submission status: Accepted

Solution code:
while True:
    m, n_min, n_max = map(int, input().split())
    if m == 0:
        break
    p = [int(input()) for _ in range(m)]
    ans = tmp = 0
    for i in range(n_min, n_max+1):
        hoge = p[i-1] - p[i]
        if tmp <= hoge:
            tmp = hoge
            ans = i
    print(ans)

Submission status: Accepted

Solution code:
while True:
    m, n_min, n_max = map(int, raw_input().split())

    if m == 0 and n_min == 0 and n_max == 0:
        break

    P = [int(raw_input()) for _ in range(m)]

    ans, t = 0, 0

    for i in range(n_min, n_max+1):
        if t <= P[i-1] - P[i]:
            ans = i
            t = P[i-1] - P[i]
    print ans

Submission status: Accepted

Solution code:
while True:
    m, n1, n2 = map(int, input().split())
    if m == 0:
        break
    p = [int(input()) for _ in range(m)]
    p.sort(reverse = True)
    g = [p[i] - p[i - 1] for i in range(n1, n2 + 1)]
    print(n2 - g[::-1].index(min(g)))

Submission status: Accepted

Solution code:
while True:
    m, nl, nu = map(int, input().split())
    if m == 0:
        break

    p = [int(input()) for i in range(m)]
    gap = ans = 0
    for n in range(nl, nu + 1):
        if p[n - 1] - p[n] >= gap:
            gap = p[n - 1] - p[n]
            ans = n
    print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,ni,na = LI()
        if n == 0:
            break
        a = sorted([I() for _ in range(n)], reverse=True)
        r = 0
        mi = -1
        for i in range(ni, na+1):
            tr = a[i-1] - a[i]
            if r <= tr:
                r = tr
                mi = i
        rr.append(mi)

    return '\n'.join(map(str, rr))


print(main())

Submission status: Accepted

Solution code:
while True:
    P = list()
    ans = list()
    tans = list()
    m, Mn, Mx = map(int, input().split())
    if m == 0 and Mn == 0 and Mx == 0:
        break
    for i in range(0, m):
        P.append(int(input()))

    for j in range(Mn-1, Mx, 1):
        ans.append(P[j]-P[j+1])
    #print(ans)
    for k in range(0,len(ans)):
        if ans[k] == max(ans):
            tans.append(k)
    #print(tans)
    print(max(tans)+Mn)

Submission status: Accepted

Solution code:
da = list(map(int,input().split()))
k = []
while sum(da) != 0:
	for i in range(da[0]):
		k.append(int(input()))
	for i in range(da[0]):
		k[da[0] - 1 -i] = k[da[0] - 1 -i] - k[da[0]-2 -i]


	pp = k[da[1]:da[2]+1]
	qq = min(pp)

	for i in range(len(pp)):
		if pp[i] == qq:
			jj = i

	print(da[1]+jj)

	da = list(map(int,input().split()))
	k = []

Submission status: Accepted

Solution code:
while True:
    m, n_min, n_max = map(int, input().split())
    if (m+n_min+n_max) == 0:
        break
    else:
        score = []
        before = 0
        dif = 0
        num = 0
        for i in range(1, m+1):
            s = int(input())
            if n_min+1 <= i <= n_max+1:
                if before - s >= dif:
                    num = i - 1
                    dif = before - s
            before = s
        print(num)

Submission status: Accepted

Solution code:
while(True):
    try:
        m, n_min, n_max = map(int, input().split())
        Ps = sorted(list(int(input()) for i in range(m)), reverse=True)
        max_v = 0
        ans = 0
        if m == 0:
            break
        for i in range(n_min, n_max+1):
            if i == len(Ps):
                break
            if max_v <= Ps[i-1]-Ps[i]:
                max_v = Ps[i-1]-Ps[i]
                ans = i
        print(ans)
    except:
        break

Submission status: Accepted

Solution code:
while True:
    ans = [0, 0]
    m, n1, n2 = map(int, input().split())
    if m == n1 == n2 == 0:
        quit()
    p = []
    for i in range(m):
        p.append(int(input()))
    p.sort(reverse=True)
    for i in range(n1 - 1, n2):
        if ans[0] <= p[i] - p[i + 1]:
            ans[0] = p[i] - p[i + 1]
            ans[1] = i + 1
    print(ans[1])

Submission status: Accepted

Solution code:
while True:
    (m, mn, mx) = tuple(map(int, input().split()))
    if m == 0:
        break
    arr = [0 for i in range(m)]
    for i in range(m):
        arr[i] = int(input())
    arr.sort(reverse=True)
    res = []
    ap = res.append
    for i in range(mn, mx + 1):
        ap([arr[i - 1] - arr[i], i])
    res.sort(key=lambda x: x[0], reverse=True)
    reres = []
    rreap = reres.append
    maxa = res[0][0]
    for e in res:
        if e[0] < maxa:
            break
        rreap(e[1])
    reres.sort(reverse=True)
    print(reres[0])

Submission status: Accepted

Solution code:
while 1:
    m,nmi,nma=map(int,input().split())
    if not m and not nmi and not nma:break
    l=[int(input()) for _ in range(m)]
    tg=[l[:i][-1]-l[i:][0] for i in range(nmi,nma+1)]    
    print(nma-tg[::-1].index(max(tg)))

Submission status: Accepted

Solution code:
while True:
    m, n_min, n_max = map(int, input().split())
    if m == 0 and n_min == 0 and n_max == 0:
        break
    P = [0 for i in range(m)]
    for i in range(m):
        P[i] = int(input())
    
    P.sort()
    ans = 0
    ans_gap = 0
    prev = P[m - n_max - 1] 
    
    for i in range(m - n_max, m - n_min + 1):
        if P[i] != prev:
            if ans_gap < (P[i] - P[i - 1]):
                ans_gap = P[i] - P[i - 1]
                ans = m - i
        prev = P[i]
    
    print(ans)

Submission status: Accepted

Solution code:
def solve(m,na,nb):
	p = [int(input()) for i in range(m)]
	ans,gap = -1,0
	for i in range(na,nb + 1):
		if p[i - 1] - p[i] >= gap:
			gap = p[i - 1] - p[i]
			ans = i
	print(ans)
	

while True:
	m,na,nb = map(int,input().split())
	if m == 0: break
	solve(m,na,nb)

Submission status: Accepted

Solution code:
while True :
    m, n_min, n_max = map(int, input().split())
    if m == 0 and n_min == 0 and n_max == 0 :
        break
    
    P = list(int(input()) for _ in range(m))
    gap = 0
    for i in range(n_min-1, n_max) :
        x = P[i] - P[i+1]
        if x >= gap :
            gap = x
            n = i
    print(n+1)

Submission status: Accepted

Solution code:
while 1:
    m,n_min,n_max = map(int,input().split())
    if m == 0 and n_min == 0 and n_max == 0:
        break
    p  = [int(input()) for i in range(m)]
    p.sort()
    p.reverse()
    lists = list(range(n_min,n_max+1))
    ans = []
    Max = -9999999999
    ans = -9999999999
    for i in lists:
        if Max <= abs(p[i-1]-p[i]):
            Max = abs(p[i-1] - p[i])
            ans = max(ans,i)
    print(ans)

Submission status: Accepted

Solution code:
def get_input():
    data_list = input().split()
    for i in range(len(data_list)):
        data_list[i] = int(data_list[i])
    return data_list

def get_score_list(student_num):
    score_list = [None] * student_num
    for i in range(student_num):
        score_data = int(input())
        score_list[i] = score_data
    score_list = sorted(score_list, reverse=True)
    return score_list

def decide_success_student_num(score_list, min_num, max_num):
    max_diff = -float('inf')
    for i in range(min_num - 1, max_num):
        tmp_num = score_list[i] - score_list[i+1]
        if tmp_num >= max_diff:
            max_diff = tmp_num
            success_student_num = i + 1
    return success_student_num


if __name__ == "__main__":
    while True:
        student_num, min_num, max_num = get_input()
        if student_num == 0:
            break
        score_list = get_score_list(student_num)
        success_student_num = decide_success_student_num(score_list, min_num, max_num)
        print(success_student_num)

Submission status: Accepted

Solution code:
while 1:
    m, nmin, nmax = map(int,input().split())
    if m==0: break
    p = []
    ans = 0
    smax = 0
    for i in range(m):
        p.append(int(input()))
        if nmin <= i < nmax+1 and p[i-1] - p[i] >= smax:
            # print(p[i - 1], p[i], smax)
            smax = p[i-1] - p[i]
            ans = i
    print(ans)

Submission status: Accepted

Solution code:
a=[]
while True:
    m,n_min,n_max=map(int,input().split())
    if m==0 and n_min==0 and n_max==0:
        for i in range(len(a)):
            print(a[i])
        break
    else:
        p=[]
        count=0
        counter=0
        for i in range(m):
            s=int(input())
            p.append(s)
        p=sorted(p,reverse=True)
        for i in range(n_min-1,n_max):
            if counter<=int(p[i])-int(p[i+1]):
                counter=int(p[i])-int(p[i+1])
                count=i+1
        a.append(count)

Submission status: Accepted

Solution code:
def solve(a,b,c):
    scores = [int(input()) for i in range(a)]
    gap = scores[b-1] - scores[b]
    tmpans = b-1
    for i in range(b-1,c):
        tmpgap = scores[i] - scores[i+1]
        if gap <= tmpgap:
            tmpans = i
            gap = tmpgap
    print(tmpans+1)
while True:
    a,b,c = map(int,input().split())
    if a == b == c and a == 0:
        exit()
    else:
        solve(a,b,c)

Submission status: Accepted

Solution code:
while True:
	m,a,b=map(int,input().split())
	if m==a==b==0:
		exit()
	ans=10**8
	ran=-1
	q=[]
	for i in range(m):
		x=int(input())
		q.append(x)
	for i in range(m-1):
		if -q[i+1]+q[i]>=ran and a<=i+1<=b:
			ans=i+1
			ran=-q[i+1]+q[i]
	print(ans)

Submission status: Accepted

Solution code:


while True:
    m,nmi,nma = map(int,input().split())

    if m == 0:
        break

    P = []

    for i in range(m):

        p = int(input())
        P.append(p)


    ans = 0
    ap = 0

    for i in range(m-1):


        if nmi <= i+1 and i+1 <= nma and ans <= P[i]-P[i+1]:

            ans = max(ans,P[i]-P[i+1])
            ap = i+1

    print (ap)

Submission status: Accepted

Solution code:
# coding=utf-8
 
###
### for atcorder program
###
 
import sys
import math
 
# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338
 
    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []
 
        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist
 
    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)
 
    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)
 
    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans
 
mymath = mymath()
 
### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()
 
output = output()
 
### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]
 
#R = float(input())
#A.append(list(map(int,input().split())))
 
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]
 
#abc list
#abc = [chr(ord('a') + i) for i in range(26)]
 
### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")  

def get_input():
  N = []
  while True:
    try:
      N.append(input())
      #N.append(int(input()))
    except EOFError:
      break
  return N


while(True):
  M, N_min, N_max = [int(x) for x in input().split()]
  P = []

  if M == 0 and N_min == 0 and N_max == 0:
    break

  for i in range(M):
    P.append(int(input()))

  G_max = 0
  I = None

  for i in range(N_min-1, N_max):
    G = P[i] - P[i+1]
    if G >= G_max:
      G_max = G
      I = i+1
    
  print(I)

Submission status: Accepted

Solution code:
ans_list = []

while True:
    m,nmin,nmax = map(int,input().split())
    if (m,nmin,nmax) == (0,0,0):
        break
    P = sorted([int(input()) for _ in range(m)], reverse=True)
    d = -float("inf")
    # 最低点合格者を全探索
    for i in range(nmin-1,nmax):
        res = P[i] - P[i+1]
        if res >= d:
            d = res
            ans = i + 1
    ans_list.append(ans)    

for ans in ans_list:
    print(ans)

Submission status: Accepted

Solution code:
while True:
  m,n1,n2=map(int,input().split())
  if m==0 and n1==0 and n2==0:
    break
  P=[]
  A=[]
  B=[]
  for i in range(m):
    P.append(int(input()))
  
  for i in range(n1,n2+1):
    A.append(P[i-1]-P[i])
    B.append(i)
  S=[]   
  for i in range(len(A)):
    if A[i]==max(A):
      S.append(B[i])
  print(max(S))

Submission status: Accepted

Solution code:
while True:
    m, minn, maxn = map(int, input().split())
    if m == minn == maxn == 0:
        break
    P = [int(input()) for i in range(m)]
    ansd = 0
    ansi = 0
    for i in range(minn-1, maxn):
        if P[i] - P[i+1] >= ansd:
            ansd = P[i] - P[i+1]
            ansi = i+1
    print(ansi)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    m,min,max= list(map(int, input().split()))
    if m==0 and min==0 and max==0:
        break;
    P = []
    for i in range(m):
        P.append(int(input()))

    spaceMax=0
    spaceMaxIndex=0
    for i in range(min-1,max):

        if spaceMax <= P[i]-P[i+1]:
            spaceMax=P[i]-P[i+1]
            spaceMaxIndex=i+1
    print(spaceMaxIndex)

Submission status: Accepted

Solution code:
while True:
    m,n_min,n_max = list(map(int,input().split()))
    if m == 0:
        break
    v  = [int(input()) for _ in range(m)]
    
    max_gap = 0
    max_index = n_min


    for i in range(n_min,n_max+1):
        gap = v[i-1]-v[i]

        
        if gap > max_gap:
            max_gap = gap
            max_index = i
        elif gap == max_gap:
            max_index = i
            
    
    print(max_index)

Submission status: Accepted

Solution code:
def main(m, nx, nn):
    b = [int(input()) for i in range(m)]
    d = -1
    for i in range(nn, nx + 1):
        if d <= b[i - 1] - b[i]:
            d = b[i - 1] - b[i]
            ans = i
    print(ans)
while 1:
    m, nmin, nmax = map(int, input().split())
    if m == nmax == nmin == 0:
        break
    main(m,nmax, nmin)

Submission status: Accepted

Solution code:
for v in range(1000):
  s,t,u = input().split()
  s = int(s)
  t = int(t)
  u = int(u)
  if s == 0:
    break
  else:
    l = []
    m = []
    for i in range(s):
      l.append(int(input()))

    for o in range(s-1):
      w = l[o]-l[o+1]
      w = abs(w)
      m.append(w)

    m = m[t-1:u]
    mx = max(m)
    lll = len(m)
    hhh=-1
    for i in range(lll): 
      if mx==m[i]:
        hhh=i+t
    print(hhh)

Submission status: Accepted

Solution code:
import sys


from inspect import currentframe


def pri(*args):
    names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    # print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))


def solve(m, n_min, n_max, P):
    ans = n_min
    pri(P)
    gap = P[n_min - 1] - P[n_min]
    pri(gap)

    for i in range(n_min - 1, n_max):
        if gap <= P[i] - P[i+1]:
            gap = P[i] - P[i+1]
            ans = i + 1
            pri(ans)
            pri(gap)
    print(ans)

    return


if __name__ == '__main__':
    while True:
        m_input, n_min_input, n_max_input = map(int, input().split())
        if m_input == n_min_input == n_max_input == 0:
            break
        P_imput = [int(input()) for _ in range(m_input)]

        solve(m_input, n_min_input, n_max_input, P_imput)

Submission status: Accepted

Solution code:
while True:
    m,nmin,nmax = [int(x) for x in input().split()]
    if m == nmin == nmax == 0:
        break
    a = [0]
    for i in range(m):
        a.append(int(input()))

    ans = 0
    ans_index = nmin

    for n in range(nmin,nmax+1):
        if ans <= a[n]-a[n+1]:
            ans = a[n]-a[n+1]
            ans_index=n

    print(ans_index)

Submission status: Accepted

Solution code:
while True:
    can_n, pass_min, pass_max = [int(i) for i in input().split()]
    if can_n == pass_min == pass_max == 0:
    	break
    	
    score_lst = []
    for _ in range(can_n):
    	score_lst.append(int(input()))
    
    gap_lst = []
    for i in range(pass_min, pass_max + 1):
    	gap_lst.append(score_lst[i - 1] - score_lst[i])
    
    gap_max = max(gap_lst)	
    for i in range(len(gap_lst) - 1, -1, -1):
    	if gap_lst[i] == gap_max:
    		print(i + pass_min)
    		break