Problem:


問題 2: 　投票 (Vote)

問題

20XX年に東京で世界的なスポーツ大会が開かれることになった．プログラミングコンテストはスポーツとして世界で楽しまれており，競技として採用される可能性がある．採用される競技を決める審査委員会について調べたところ，次のようなことが分かった．

審査委員会のために，候補となる N 個の競技を面白い方から順番に並べたリストが作成された．リストの上から i 番目には i 番目に面白い競技が書かれている．それを競技 i とする．さらに競技 i の開催に必要な費用 Ai が書かれている．

また，審査委員会は委員 1 から委員 M までの M 人の委員で構成されている．委員 j は自分の審査基準 Bj をもっており，開催に必要な費用が Bj 以下の競技のうち最も面白いものに 1 票を投票した．

どの委員の審査基準に対しても，少なくとも 1 つの競技は開催に必要な費用が審査基準以下であった．したがって，委員は全員 1 票を投票した．

最も多く票を獲得した競技は 1 つだけであった．

競技のリストと委員の情報が与えられたとき，最も多く票を獲得した競技の番号を求めるプログラムを作成せよ．

 入力

入力は 1 + N + M 行からなる．

1 行目には整数 N, M  (1 ≤ N ≤ 1000，1 ≤ M ≤ 1000) が書かれており，それぞれ競技の数，委員の数を表す．

続く N 行のうちの i 行目 (1 ≤ i ≤ N) には整数 Ai (1 ≤ Ai ≤ 1000) が書かれており， 競技 i の開催に必要な費用 Ai を表す．

続く M 行のうちの j 行目 (1 ≤ j ≤ M) には整数 Bj (1 ≤ Bj ≤ 1000) が書かれており，委員 j の審査基準 Bj を表す．

与えられる入力データにおいては，どの委員も必ず 1 票を投票し，最も多く票を獲得した競技は 1 つであることが保証されている．

出力

最も多く票を獲得した競技の番号を 1 行で出力せよ．

入出力例

入力例 1

  

4 3
5
3
1
4
4
3
2

出力例 1

   

2

入出力例 1 では，競技は 4 つあり，委員は 3 人いる．リストの 4 つの競技にかかる費用はそれぞれ 5, 3, 1, 4 である．

委員 1 の審査基準は 4 である．費用が 4 以下の競技のうち最も面白いものは競技 2 である．

委員 2 の審査基準は 3 である．費用が 3 以下の競技のうち最も面白いものは競技 2 である．

委員 3 の審査基準は 2 である．費用が 2 以下の競技のうち最も面白いものは競技 3 である．

よって，競技 2 が 2 票，競技 3 が 1 票を獲得する．最も多く票を獲得した競技は競技 2 であるので，2 を出力する．

入力例 2
 

  

6 6
3
1
4
1
5
9
2
6
5
3
5
9

出力例 2

   

1

入出力例 2 では，競技 1 が 5 票，競技 2 が 1 票を獲得する．最も多く票を獲得した競技は競技 1 なので，1 を出力する．

問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample input:
4 3
5
3
1
4
4
3
2


Sample output:
2

Submission status: Wrong Answer

Solution code:
# coding: utf-8

N, M = list(map(int, input().split(' ')))
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(M)]
scores = [0 for _ in range(N)]

for j in range(M):
    for i in range(N):
        if A[i] <= B[j]:
            scores[i] += 1
            break

max_i, max_val = 0, 0
for i in range(1, N):
    if scores[i] > max_val:
        max_val = scores[i]
        max_i = i
print(max_i + 1)

Submission status: Wrong Answer

Solution code:
import sys
def line():return sys.stdin.readline().strip()
def cin():return sys.stdin.readline().strip().split()
N,M = [int(i) for i in cin()]
A = [int(line()) for _ in range(N)]
C = [0] * N
for i in range(M):
    B = int(line())
    for j in range(N):
        if A[j] <= B:
            C[j]+=1
            break
print(max(C,key=C.index) + 1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(M)]

votes = [0] * N
for x in B:
    for i, v in enumerate(A):
        if x - v > -1:
            votes[i] += 1
            break
print(max(votes, key=votes.index) + 1)

Submission status: Wrong Answer

Solution code:
def main():
  n,m = map(int,input().split())
  A = [int(input()) for _ in range(n)]
  V = [0 for _ in range(n)]
  m = 0
  ans = 0
  for i in range(m):
    b = int(input())
    for j in range(n):
      if A[j] <= b:
        V[j] += 1
        if m < V[j]:
          m += 1
          ans = j
        break
  print(ans + 1)

main()

Submission status: Accepted

Solution code:
# coding: utf-8

N, M = list(map(int, input().split(' ')))
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(M)]
scores = [0 for _ in range(N)]

for j in range(M):
    for i in range(N):
        if A[i] <= B[j]:
            scores[i] += 1
            break

max_i, max_val = 0, 0
for i in range(N):
    if scores[i] > max_val:
        max_val = scores[i]
        max_i = i
print(max_i + 1)

Submission status: Accepted

Solution code:
(n, m) = map(int, raw_input().split())

a = [input() for i in range(n)]
b = [input() for i in range(m)]

c = [0 for i in range(n)]

for i in range(m):
  for j in range(n):
    if a[j] <= b[i]:
      c[j] += 1
      break

mx = max(c)
for i in range(n):
  if c[i] == mx:
    print i + 1

Submission status: Accepted

Solution code:
[N,M]=[int(x) for x in raw_input().split()]
pricelist=[]
buylist=[]
for i in range(1,N+1):
    pricelist.append((int(raw_input()),i))
for j in range(M):
    buylist.append(int(raw_input()))
pricelist.sort()
buylist.sort()
finalwinner=[99999,0]
winner=[99999,0]
ind=0
for b in buylist:
    localwinner=winner[0]
    while(pricelist[ind][0]<=b and ind<N-1):
        localwinner=min(localwinner,pricelist[ind][1])
        ind+=1
    if winner[0]==localwinner:
        winner[1]+=1
    else:
        finalwinner=max([finalwinner,winner], key=lambda x: x[1])
        winner=[localwinner,1]
    #print winner
finalwinner=max([finalwinner,winner], key=lambda x: x[1])
print finalwinner[0]

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
a = [input() for i in range(n+k)]
cnt = {i:0 for i in range(n)}
for i in range(n,n+k):
    for j in range(n):
        if a[i] >= a[j]:
            cnt[j] += 1
            break
print sorted(cnt.items(), key = lambda x:x[1], reverse = True)[0][0] + 1

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
a = [input() for i in range(n+k)]
c = [0]*n
for i in range(n,n+k):
    for j in range(n):
        if a[i] >= a[j]:
            c[j] += 1
            break
print c.index(max(c)) + 1

Submission status: Accepted

Solution code:
import sys
def line():return sys.stdin.readline().strip()
def cin():return sys.stdin.readline().strip().split()
N,M = [int(i) for i in cin()]
A = [int(line()) for _ in range(N)]
C = [0] * N
for i in range(M):
    B = int(line())
    for j in range(N):
        if A[j] <= B:
            C[j]+=1
            break
print(max(range(len(C)),key=lambda i:C[i]) + 1)

Submission status: Accepted

Solution code:
n,m=map(int,raw_input().split())
k=[int(raw_input()) for _ in xrange(n)]
s=[int(raw_input()) for _ in xrange(m)]
vote=[0]*n
for i in xrange(m):
    for j in xrange(n):
        if k[j]<=s[i]:
            vote[j]+=1
            break
print(vote.index(max(vote))+1)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
v=[0]*n
a=[int(input()) for _ in range(n)]
b=[int(input()) for _ in range(m)]
for i in b:
    for j in range(n):
        if a[j]<=i:
            v[j]+=1
            break
print(v.index(max(v))+1)

Submission status: Accepted

Solution code:
n,m=[int(s)for s in input().split(" ")]
intr=[int(input())for i in range(n)]
crit=[int(input())for i in range(m)]
vote=[0 for i in range(n)]
for c in crit:
    for i in range(n):
        if intr[i]<=c:
            vote[i]+=1
            break
print(vote.index(max(vote))+1)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(M)]

ans = []
for x in B:
    for i, v in enumerate(A):
        if x - v > -1:
            ans.append(i)
            break
print(max(ans, key=ans.count) + 1)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(M)]

votes = [0] * N
for x in B:
    for i, v in enumerate(A):
        if x - v > -1:
            votes[i] += 1
            break
print(votes.index(max(votes)) + 1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0593

"""
import sys
from sys import stdin
from collections import namedtuple, Counter
input = stdin.readline


class RMQ(object):
    INT_MAX = 2**31 - 1

    def __init__(self, nn, init_val=0):
        self.n = 1
        while self.n < nn:
            self.n *= 2
        self.dat = [init_val] * ((2 * self.n)-1)

    def update(self, k, a):
        # A[k]???a?????´??°?????????????????°???????????¨?????´??°
        k += (self.n - 1)
        self.dat[k] = a

        while k > 0:
            k = (k - 1) // 2        #  ??????index??????
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2]) #  ???????????¨??????????????????????°?????????????????????´??°

    def query(self, a, b, k, l, r):
        # [a, b)???????°????????±??????? (0????????§b???????????????)
        # ??????????????¨?????????query(a, b, 0, 0, n)?????¢??§??????????????????k, l, r???????????????????????´??°?????????
        if r <= a or b <= l:        #  ?????????????????§??¨??????????????????
            return RMQ.INT_MAX
        if a <=l and r <= b:
            return self.dat[k]           #  ???????????°???????????????????????§????????°????????¨??????????????????????°?????????????????????????
        else:
            vl = self.query(a, b, k*2+1, l, (l+r)//2) #  ????????°????????????????°????
            vr = self.query(a, b, k*2+2, (l+r)//2, r) #  ????????°????????????????°????
            return min(vl, vr)

    def find(self, s, t):
        return self.query(s, t+1, 0, 0, self.n)



event = namedtuple('event', ['num', 'cost'])
def main(args):
    N, M = map(int, input().split())
    rq = RMQ(1001, 999999)
    events = [event(i+1, int(input())) for i in range(N)]
    events.reverse()
    for e in events:
        rq.update(e.cost, e.num)

    # ????\¨
    votes = []
    for _ in range(M):
        v = int(input())
        result = rq.find(0, v)
        votes.append(result)
    ans = Counter(votes).most_common(1)[0][0]
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0593

"""
import sys
from sys import stdin
from collections import namedtuple, Counter
input = stdin.readline


class RMQ(object):
    INT_MAX = 2**31 - 1

    def __init__(self, nn, init_val=0):
        self.n = 1
        while self.n < nn:
            self.n *= 2
        self.dat = [init_val] * ((2 * self.n)-1)

    def update(self, k, a):
        # A[k]???a?????´??°?????????????????°???????????¨?????´??°
        k += (self.n - 1)
        self.dat[k] = a

        while k > 0:
            k = (k - 1) // 2        #  ??????index??????
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2]) #  ???????????¨??????????????????????°?????????????????????´??°

    def query(self, a, b, k, l, r):
        # [a, b)???????°????????±??????? (0????????§b???????????????)
        # ??????????????¨?????????query(a, b, 0, 0, n)?????¢??§??????????????????k, l, r???????????????????????´??°?????????
        if r <= a or b <= l:        #  ?????????????????§??¨??????????????????
            return RMQ.INT_MAX
        if a <=l and r <= b:
            return self.dat[k]           #  ???????????°???????????????????????§????????°????????¨??????????????????????°?????????????????????????
        else:
            vl = self.query(a, b, k*2+1, l, (l+r)//2) #  ????????°????????????????°????
            vr = self.query(a, b, k*2+2, (l+r)//2, r) #  ????????°????????????????°????
            return min(vl, vr)

    def find(self, s, t):
        return self.query(s, t+1, 0, 0, self.n)


event = namedtuple('event', ['num', 'cost'])
def main(args):
    N, M = map(int, input().split())
    rq = RMQ(1001, 999999)
    events = [event(i+1, int(input())) for i in range(N)] #  ??¶????????????1??????????????§???i+1???????????????
    events.reverse()            #  ??¢?????????????????????????????¶???????????¨?????????????????????
    #  ?????????(e.cost)??§????????§????????¶????????????(e.num)??§RMQ?????´??°????????????
    # events???????´????????????????????????¢??????????????\??£??????????????§???????????????????????¶???????????£?????´????????¢??????????????¶???????????§??????????????????
    for e in events:
        rq.update(e.cost, e.num)

    # ????\¨
    # votes = []
    # for _ in range(M):
    #     v = int(input())
    #    result = rq.find(0, v)  #  ?????????v?????§???????????????????????§??????????????¢????????¶????????????
    #    votes.append(result)
    votes = [rq.find(0, int(input())) for _ in range(M)]
    ans = Counter(votes).most_common(1)[0][0]
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0593

"""
import sys
from sys import stdin
from collections import namedtuple, Counter
input = stdin.readline


class RMQ(object):
    INT_MAX = 2**31 - 1

    def __init__(self, nn, init_val=0):
        self.n = 1
        while self.n < nn:
            self.n *= 2
        self.dat = [init_val] * ((2 * self.n)-1)

    def update(self, k, a):
        # A[k]???a?????´??°?????????????????°???????????¨?????´??°
        k += (self.n - 1)
        self.dat[k] = a

        while k > 0:
            k = (k - 1) // 2        #  ??????index??????
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2]) #  ???????????¨??????????????????????°?????????????????????´??°

    def query(self, a, b, k, l, r):
        # [a, b)???????°????????±??????? (0????????§b???????????????)
        # ??????????????¨?????????query(a, b, 0, 0, n)?????¢??§??????????????????k, l, r???????????????????????´??°?????????
        if r <= a or b <= l:        #  ?????????????????§??¨??????????????????
            return RMQ.INT_MAX
        if a <=l and r <= b:
            return self.dat[k]           #  ???????????°???????????????????????§????????°????????¨??????????????????????°?????????????????????????
        else:
            vl = self.query(a, b, k*2+1, l, (l+r)//2) #  ????????°????????????????°????
            vr = self.query(a, b, k*2+2, (l+r)//2, r) #  ????????°????????????????°????
            return min(vl, vr)

    def find(self, s, t):
        return self.query(s, t+1, 0, 0, self.n)


event = namedtuple('event', ['num', 'cost'])
def main(args):
    N, M = map(int, input().split())
    rq = RMQ(1001, 999999)
    events = [event(i+1, int(input())) for i in range(N)] #  ??¶????????????1??????????????§???i+1???????????????
    events.reverse()            #  ??¢?????????????????????????????¶???????????¨?????????????????????
    #  ?????????(e.cost)??§????????§????????¶????????????(e.num)??§RMQ?????´??°????????????
    # events???????´????????????????????????¢??????????????\??£??????????????§???????????????????????¶???????????£?????´????????¢??????????????¶???????????§??????????????????
    for e in events:
        rq.update(e.cost, e.num)

    # ????\¨
    votes = []
    for _ in range(M):
        v = int(input())
        result = rq.find(0, v)  #  ?????????v?????§???????????????????????§??????????????¢????????¶????????????
        votes.append(result)
    ans = Counter(votes).most_common(1)[0][0]
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
from collections import Counter

kyougi, iin = list(map(int, input().split(' ')))

kyougi_costs = {}
for i in range(1, kyougi+1):
    kyougi_costs[i] = int(input())

iin_likes = {}
for i in range(1, iin+1):
    iin_likes[i] = int(input())

vote = []
for iin, like in iin_likes.items():
    max_interest = -1
    tmp_kyougi = []
    for kyougi, cost in kyougi_costs.items():
        if like >= cost:
            tmp_kyougi.append(kyougi)
    vote.append(min(tmp_kyougi))

c = Counter(vote)
for key, value in c.items():
    if value == max(c.values()):
        print(key)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [int(input()) for _ in range(n)]
b = [0] * n
for _ in range(m):
    v = int(input())
    for i in range(n):
        if a[i] <= v:
            b[i] += 1
            break
print(b.index(max(b)) + 1)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
A = [int(input()) for _ in range(n)]
V = [0 for _ in range(n)]
for i in range(m):
  b = int(input())
  for j in range(n):
    if A[j] <= b:
      V[j] += 1
      break

print(V.index(max(V)) + 1)

Submission status: Accepted

Solution code:
def main():
  n,m = map(int,input().split())
  A = [int(input()) for _ in range(n)]
  V = [0 for _ in range(n)]
  for i in range(m):
    b = int(input())
    for j in range(n):
      if A[j] <= b:
        V[j] += 1
        break
  print(V.index(max(V)) + 1)

main()

Submission status: Accepted

Solution code:
def main():
  n,m = map(int,input().split())
  A = [int(input()) for _ in range(n)]
  V = [0 for _ in range(n)]
  M = 0
  ans = 0
  for i in range(m):
    b = int(input())
    for j in range(n):
      if A[j] <= b:
        V[j] += 1
        if M < V[j]:
          M += 1
          ans = j
        break
  print(ans + 1)

main()

Submission status: Accepted

Solution code:
# AOJ 0593: Vote
# Python3 2018.6.30 bal4u

n, m = map(int, input().split())
a = []
c = [0]*n
for i in range(n): a.append(int(input()))
for j in range(m):
	b = int(input())
	for i in range(n):
		if a[i] <= b:
			c[i] += 1
			break
print(1+c.index(max(c)))

Submission status: Accepted

Solution code:
n, m = map(int, raw_input().split())
A = [input() for i in range(n)]
B = [input() for i in range(m)]
vote = [0] * n
for b in B:
    for i, a in enumerate(A):
        if a <= b:
            vote[i] += 1
            break
print vote.index(max(vote)) + 1

Submission status: Accepted

Solution code:
n,m=map(int,raw_input().split())
v=[0]*n
a=[input() for i in [1]*n]
b=[input() for i in [1]*m]
for c in b:
	for i in range(n):
		if a[i]<=c:
			v[i]+=1
			break
print v.index(max(v))+1

Submission status: Accepted

Solution code:
n,m=map(int,raw_input().split())
v=[0]*n
a=[int(raw_input()) for i in [1]*n]
b=[int(raw_input()) for i in [1]*m]
for c in b:
	for i in range(n):
		if a[i]<=c:
			v[i]+=1
			break
print v.index(max(v))+1

Submission status: Accepted

Solution code:
n, m = map(int, raw_input().split())
a = [[input(),i] for i in xrange(n)]
t = [[0,i+1] for i in xrange(n)]
for b in [input() for i in xrange(m)]:
    t[filter(lambda x: x[0]<=b, a)[0][1]][0] += 1
print sorted(t, reverse=True)[0][1]

Submission status: Accepted

Solution code:
n, m = raw_input().strip().split(' ')

n = int(n)
m = int(m)

a = [0] * n
b = [0] * m
c = [0] * n
ans = 1
ansv = 0

for i in range(n) :
	a[i] = input()

for i in range(m) :
	b = input()
	for j in range(n) :
		if (a[j] <= b) :
			c[j] += 1;
			if (c[j] > ansv) :
				ansv = c[j]
				ans = j + 1
			break

print ans

Submission status: Accepted

Solution code:
import math
n,m = map(int,input().split())

A = [int(input()) for i in range(n)]
B = [int(input()) for i in range(m)]
v = [0 for i in range(n)]

for i in range(m):
    for j in range(n):
        if B[i] >= A[j]:
            v[j] += 1
            break

print(v.index(max(v))+1)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
Cost = [int(input()) for i in range(N)]
Man = [int(input()) for i in range(M)]
Cnt = [0 for i in range(N)]

for i in range(M) :
    j = 0
    while True :
        if Cost[j] <= Man[i] :
            Cnt[j] += 1
            break
        else :
            j += 1
print(Cnt.index(max(Cnt))+1)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [int(input()) for i in range(N)]  #費用
R = [0]*N  #投票数
for _ in range(M):
	B = int(input())
	for i in range(len(A)):
		if B>=A[i]:
			R[i] += 1
			break

#print(R)
maxvalue = max(R)
for i in range(len(R)):
	if maxvalue==R[i]:
		print(i+1)
		exit(0)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
A=[int(input()) for i in range(n)]
B=[int(input()) for i in range(m)]
I=[0 for i in range(n)]
for i in range(m):
    for j in range(n):
        if B[i]>=A[j]:
            I[j]+=1
            break
print(I.index(max(I))+1)

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
a = []
b = []

for i in range(n):
    a.append(int(input()))
for i in range(m):
    b.append(int(input()))

rank = [0]*n

for i in b:
    for j in range(n):
        if i >= a[j]:
            rank[j] += 1
            break

print(rank.index(max(rank))+1)

Submission status: Accepted

Solution code:
#B問題
N,M = map(int,input().split())
A = [int(input()) for i in range(N)]
B = [int(input()) for j in range(M)]
C = [0 for i in range(N)]
for j in range(M):
    b = B[j]
    for i in range(N):
        if A[i] <= b:
            C[i]+=1
            break
            
c = max(C)
print(C.index(c)+1)

Submission status: Accepted

Solution code:

n, m = [int(x) for x in input().split()]
L = []
c=0
for _ in range(n):
    c += 1
    a = int(input())
    L.append((c,a))

V = [0] * (n+1)
for _ in range(m):
    b = int(input())
    for i,a in L:
        if a <=b:
            V[i] += 1
            break
v = max(V)
t = V.index(v)

print(t)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[int(input()) for _ in range(n)]
b=[int(input()) for _ in range(m)]
c=[0]*n
for j in range(m):
    for i in range(n):
        if a[i]<=b[j]:
            c[i]+=1
            break
print(c.index(max(c))+1)

Submission status: Accepted

Solution code:
import collections

N,M = (int(x) for x in input().split())
fee = []
com = []
ans = []

for i in range(N):
    a = int(input())
    fee.append(a)
    
for i in range(M):
    b = int(input())
    com.append(b)
    
for i in range(M):
    k = 0
    while(com[i] < fee[k]):
        k=k+1
        
    ans.append(k)
    
c = collections.Counter(ans)
    
print(c.most_common()[0][0]+1)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(M)]

vote = [0] * N
vote_max = 0
ans = -1
for b in B:
    for i in range(N):
        if A[i] <= b:
            vote[i] += 1
            if vote_max < vote[i]:
                vote_max = vote[i]
                ans = i
            break

print(ans + 1)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

compe = []
for _ in range(n):
    a = int(input())
    compe.append(a)

vote = [0] * n
for _ in range(m):
    b = int(input())
    for i, c in enumerate(compe):
        if c <= b:
            vote[i] += 1
            break

print(vote.index(max(vote)) + 1)

Submission status: Accepted

Solution code:
N,M = map(int,(input().split()))

A = []
for i in range(N):
	n = int(input())
	A.append(n)

B = []
for i in range(M):
	n = int(input())
	B.append(n)

ans = [0 for i in range(N)]
for i in range(M):
	for j in range(N):
		if B[i] >= A[j]:
			ans[j] += 1
			break

Max = 0
idx = 0
for i in range(N):
	if Max < ans[i]:	
		Max = ans[i]
		idx = i + 1

print(idx)

Submission status: Runtime Error

Solution code:
# coding: utf-8

import numpy as np

N, M = list(map(int, input().split(' ')))
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(M)]
scores = [0 for _ in range(N)]

for j in range(M):
    for i in range(N):
        if A[i] <= B[j]:
            scores[i] += 1
            break

print(np.argmax(scores) + 1)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0593

"""
import sys
from sys import stdin
from collections import namedtuple, Counter
input = stdin.readline


class RMQ(object):
    INT_MAX = 2**31 - 1

    def __init__(self, nn, init_val=0):
        self.n = 1
        while self.n < nn:
            self.n *= 2
        self.dat = [init_val] * ((2 * self.n)-1)

    def update(self, k, a):
        # A[k]???a?????´??°?????????????????°???????????¨?????´??°
        k += (self.n - 1)
        self.dat[k] = a

        while k > 0:
            k = (k - 1) // 2        #  ??????index??????
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2]) #  ???????????¨??????????????????????°?????????????????????´??°

    def query(self, a, b, k, l, r):
        # [a, b)???????°????????±??????? (0????????§b???????????????)
        # ??????????????¨?????????query(a, b, 0, 0, n)?????¢??§??????????????????k, l, r???????????????????????´??°?????????
        if r <= a or b <= l:        #  ?????????????????§??¨??????????????????
            return RMQ.INT_MAX
        if a <=l and r <= b:
            return self.dat[k]           #  ???????????°???????????????????????§????????°????????¨??????????????????????°?????????????????????????
        else:
            vl = self.query(a, b, k*2+1, l, (l+r)//2) #  ????????°????????????????°????
            vr = self.query(a, b, k*2+2, (l+r)//2, r) #  ????????°????????????????°????
            return min(vl, vr)

    def find(self, s, t):
        return self.query(s, t+1, 0, 0, self.n)


event = namedtuple('event', ['num', 'cost'])
def main(args):
    N, M = map(int, input().split())
    rq = RMQ(1001, 999999)
    events = [event(i+1, int(input())) for i in range(N)] #  ??¶????????????1??????????????§???i+1???????????????
    events.reverse()            #  ??¢?????????????????????????????¶???????????¨?????????????????????
    #  ?????????(e.cost)??§????????§????????¶????????????(e.num)??§RMQ?????´??°????????????
    # events???????´????????????????????????¢??????????????\??£??????????????§???????????????????????¶???????????£?????´????????¢??????????????¶???????????§??????????????????
    for e in events:
        rq.update(e.cost, e.num)

    # ????\¨
    votes = []
    for _ in range(M):
        v = int(input())
       result = rq.find(0, v)  #  ?????????v?????§???????????????????????§??????????????¢????????¶????????????
       votes.append(result)
    ans = Counter(votes).most_common(1)[0][0]
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [int(input()) for i in range(n)]
b = [int(input()) for i in range(m)]
no = [114514] * 1919

for i, t in enumerate(a):
    no[t] = i + 1
for i in range(1145):
    no[i + 1] = min(no[i + 1], no[i])

from collections import Counter
c = Counter()
for t in b:
    c[no[t]] += 1
print(c.most_common(1)[0][0])