Problem:


Score : 300 points

Problem Statement

There is an empty array.
The following N operations will be performed to insert integers into the array.
In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.
Find the K-th smallest integer in the array after the N operations.
For example, the 4-th smallest integer in the array \{1,2,2,3,3,3\} is 3.

Constraints

1≤N≤10^5 

1≤a_i,b_i≤10^5 

1≤K≤b_1…+…b_n

All input values are integers.

Input

Input is given from Standard Input in the following format:  

N K
a_1 b_1
:  
a_N b_N

Output

Print the K-th smallest integer in the array after the N operations.  

Sample Input 1

3 4
1 1
2 2
3 3

Sample Output 1

3

The resulting array is the same as the one in the problem statement.

Sample Input 2

10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000

Sample Output 2

1



Sample input:
3 4
1 1
2 2
3 3


Sample output:
3

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
tmp = []
for i in range(0, n):
    a, b = map(int, input().split())
    tmp += [a for j in range(0, b)]
tmp = sorted(tmp) 
print(tmp[k-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
tmp = []
for i in range(0, n):
    a, b = map(int, input().split())
    tmp += [a for j in range(0, b)]
tmp.sort()
print(tmp[k-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(x) for x in input().split()]

array = []
for i in range(N):
    a, b = [int(x) for x in input().split()]
    array.extend([a for x in range(b)])

array.sort()
print(array[K-1])

Submission status: Time Limit Exceeded

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

line = input().split(' ')
N = int(line[0])
K = int(line[1])

out = []

for i in range(N):
    line = input().split(' ')
    a = int(line[0])
    b = int(line[1])
    for j in range(b):
        out.append(a)

if __name__ == '__main__':
    out = sorted(out)
    print(out[K-1])

Submission status: Time Limit Exceeded

Solution code:
table = input().split()
N,K = int(table[0]),int(table[1])
hairetu = []
for i in range(N):
    ith = input().split()
    hairetu += [ith[0] for j in range(0,int(ith[1]))]
hairetu = list(map(int,hairetu))
hairetu.sort()
print(hairetu[K-1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
import numpy as np
N, K = map(int, raw_input().split())

def test():
    ia, ib = map(int, raw_input().split())
    return np.ones(ib) * ia

R = np.array([_ for i in xrange(N) for _ in test()])
print int(np.sort(R)[K-1])

Submission status: Time Limit Exceeded

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

c = []

for i in range(N):
	c.append(input().split())

d = []
e = []

for j in range(N):
	e.append(c[j][0])
	e = e * int(c[j][1])
	d = d + e
	e = []

d.sort()

print(d[K-1])

Submission status: Time Limit Exceeded

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

array = []
hoge  = []
n, k  = map(int, raw_input().split())

for i in xrange(n):
	a, b  = map(int, raw_input().split())
	array.append([a, b])

array.sort()
#print(array)

for i in range(len(array)):
	hoge += [array[i][0]] * array[i][1]
	if len(hoge) >= k:
		break

print(hoge[k - 1])

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split()))
L = []
for i in range(N):
	a, b = list(map(int, input().split()))
	for j in range(b):
		L.append(a)
L = sorted(L)
print(L[K - 1])

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8


def add_list(_n):
    _l = []
    for _ in range(_n):
        a, b = map(int, raw_input().split())
        _l.append([a for _ in range(b)])
    return [j for i in _l for j in i]

n, k = map(int, raw_input().split())
l = add_list(n)
l.sort()
print l[k-1]

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
ls = []
b_num = 0

for i in range(n):
    a,b = [int(i) for i in input().split()]
    if b_num < k:
        tmp = [a] * b
        ls.extend(tmp)
        #ls.sort()
        b_num += b
    else:
        if(a <= max(ls)):
            tmp = [a] * b
            ls.extend(tmp)

ls.sort()
print(ls[k-1])

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,raw_input().split(' '))
arr = []
a_count = {}
for i in xrange(n):
    a,b = map(int,raw_input().split(' '))
    if not a in arr:
        arr.append(a)
        a_count.update({a:b})
    else:
        a_count[a] += b
        
        
arr.sort()
cnt = 0

for i in arr:
    cnt += a_count[i]
    if k <=cnt:
        print i
        break

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
ls = []
b_num = 0

for i in range(n):
    a,b = [int(i) for i in input().split()]
    if b_num <= k:
        tmp = [a] * b
        ls.extend(tmp)
        ls.sort()
        b_num += b
    else:
        if(a <= ls[-1]):
            tmp = [a] * b
            ls.extend(tmp)
            ls.sort()
        
print(ls[k-1])

Submission status: Time Limit Exceeded

Solution code:
#nm = '3 4'.split(' ')
#print(abc)
nm = input().split(' ')
vv = []
ss =[]
vv.append(input().split(' '))

for i in range(int(nm[0])-1):
    a = input().split(' ')
    if int(a[0]) > int(vv[-1][0]):
        vv.append(a)
    else:
        vv.insert(0, a)

cou = 0
for i in vv:
    if  cou < int(nm[1]):    
        for f in range(int(i[0])):
            ss.append(int(i[1]))
    cou += int(i[0])



        
sub = len(ss)-1
while sub != 0:

    ss[sub], ss[ss.index(max(ss[:sub+1]))] = ss[ss.index(max(ss[:sub+1]))], ss[sub] 
    sub -= 1

print(ss[int(nm[1])])

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,raw_input().split(' '))
arr = []
for i in xrange(n):
    a,b = map(int,raw_input().split(' '))
    for _ in xrange(b):
        arr.append(a)
arr.sort()
print arr[k-1]

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,K = list(map(int,input().split()))

a = []
array = []
for i in range(N):
    a = list(map(int,input().split()))
    for j in range(a[1]):
        array.append(a[0])
#print (array)
array = np.sort(array)
node = 1

print (int(array[K-1]))

Submission status: Time Limit Exceeded

Solution code:
def flatten(nested_list):
    return [e for inner_list in nested_list for e in inner_list]
nk = input().split()
kai = int(nk[0])
banme = int(nk[1])
lis = []
i = 0
while(i < kai):
    c = input().split()
    a = int(c[0])
    b = int(c[1])
    n = 0
    tmplis = [a] * b
    lis.append(tmplis)
    i += 1
    pass
lis = flatten(lis)
slis = sorted(lis)
ans = slis[banme-1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = input().split()
n = int(n)
k = int(k)
a = []
b = []
for x in range(n):
    tmp1, tmp2 = input().split()
    a.append(int(tmp1))
    b.append(int(tmp2))
nagasa = len(a)
for j in range(nagasa):
    for i in range(nagasa):
        if a[j] <= a[i]:
            a[j], a[i] = a[i], a[j]
            b[j], b[i] = b[i], b[j]
cnt = 0
for j in range(nagasa):
    cnt += b[j]
    if cnt >= k:
        break
print(a[j])

Submission status: Time Limit Exceeded

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

array = []
n, k  = map(int, raw_input().split())

for i in xrange(n):
	a, b  = map(int, raw_input().split())
	array += [a] * b

array.sort()
print(array[k - 1])

Submission status: Time Limit Exceeded

Solution code:
#nm = '3 4'.split(' ')
#print(abc)
nm = input().split(' ')
vv = []
for i in range(int(nm[0])):
    a = input().split(' ')
    for i in range(int(a[0])):
        vv.append(int(a[1]))
        
sub = len(vv)-1
while sub != 0:

    vv[sub], vv[vv.index(max(vv[:sub+1]))] = vv[vv.index(max(vv[:sub+1]))], vv[sub] 
    sub -= 1

print(vv[int(nm[1])-1])

Submission status: Time Limit Exceeded

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

for i in range(n):
    x, y = map(int, input().split())
    for j in range(y):
        a.append(x)

a.sort()
print (a[k-1])

Submission status: Time Limit Exceeded

Solution code:
nk = input().split()
kai = int(nk[0])
banme = int(nk[1])
lis = []
i = 0
while(i < kai):
    c = input().split()
    a = int(c[0])
    b = int(c[1])
    n = 0
    while(n < b):
        lis.append(a)
        n += 1
        pass
    i += 1
    pass
slis = sorted(lis)
ans = slis[banme-1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
ls = []

for i in range(n):
    a,b = [int(i) for i in input().split()]
    tmp = [a] * b
    ls.append(tmp)

ls = sum(ls,[])
ls.sort()
print(ls[k-1])

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
list=[]
for i in range(n):
    a,b=map(int,input().split())
    for j in range(b): list.append(a)

list.sort()
ans=list[k-1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def rren(): return list(map(int, input().split()))


a = set()
b = dict()
N, K = rren()

for i in range(N):
    a_t, b_t = rren()
    if(a_t not in a):
        a.add(a_t)
        b[a_t] = b_t
    else:
        b[a_t] += b_t

count = K
for i in range(K-1):
    mn = min(a)
    nu = b[mn]
    a.discard(mn)
    count -= nu
    if(count <= 0):
        print(mn)
        break

Submission status: Time Limit Exceeded

Solution code:
import collections

d={}
N,K=map(int,raw_input().split())

for i in xrange(N):
    a,b=map(int,raw_input().split())
#    print a,b
    if a in d:
        d[a] = d[a] + b
    else:
        d[a]=b
    td={}
    cnt=0
#    print d
    for key in sorted(d):
#        print key
        if cnt<=K:
            td[key]=d[key]
        else:
            break
    d=td

aa=None
cnt=0
#print d
for k in sorted(d):
    aa=k
    cnt+=d[k]
#    print cnt
    if cnt>=K:
        break
print aa

Submission status: Time Limit Exceeded

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

array = []
n, k  = map(int, raw_input().split())

for i in xrange(n):
	a, b  = map(int, raw_input().split())
	hoge = [a] * b
	array += hoge

array.sort()
print(array[k - 1])

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8


def add_list(_n):
    _l = []
    for _ in range(_n):
        a, b = map(int, raw_input().split())
        for i in range(b):
            _l.append(a)
    return _l

n, k = map(int, raw_input().split())
l = add_list(n)
l.sort()

print l[k-1]

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
list = []
i = 0
while i < N:
    a, b = map(int, input().split())
    list += [a]*b
    i += 1
list.sort()
print(list[K-1])

Submission status: Time Limit Exceeded

Solution code:
def C(_mid):
    if _mid <= target_list[K - 1]:
        return True
    else:
        return False


N, K = list(map(int, input().split()))
target_list = []
ab = []
for i in range(N):
    a, b = list(map(int, input().split()))
    ab.append([a, b])

ab.sort(key=lambda x: x[0])
# print(ab)

for i in range(N):
    for j in range(ab[i][1]):
        target_list.append(ab[i][0])

# print(target_list)

lb = 1
ub = 100000
while ub - lb > 1:
    # print(str(lb) + " " + str(ub))
    mid = int((lb + ub) / 2)
    if C(mid):
        lb = mid
    else:
        ub = mid

print(lb)

Submission status: Time Limit Exceeded

Solution code:
def rren(): return list(map(int, input().split()))


a = []
b = []
N, K = rren()

for i in range(N):
    a_t, b_t = rren()
    a.append(a_t)
    b.append(b_t)

count = K
for i in range(K-1):
    mn = min(a)
    ind = a.index(min(a))
    nu = b[ind]
    del a[ind]
    del b[ind]
    count -= nu
    if(count <= 0):
        print(mn)
        break

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
list = []
for i in range(0, N):
    a, b = map(int, input().split())
    list += [a]*b
list.sort()
print(list[K-1])

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int, input().split())
    ary = []
    i = 0
    while i < N:
        a, b = map(int, input().split())
        ary += [a] * b
        i += 1

    ans = sorted(ary)[K-1]
    print(ans)

main()

Submission status: Time Limit Exceeded

Solution code:
n, k = input().split()
n = int(n)
k = int(k)
array = []
for _ in range(n):
    tmp1, tmp2 = input().split()
    tmp1 = int(tmp1)
    tmp2 = int(tmp2)
    for dummy in range(tmp2):
        array.append(tmp1)
array.sort()
print(array[k - 1])

Submission status: Time Limit Exceeded

Solution code:
N,K=list(map(int,input().split()))
print(sorted(sum([[a[0]]*a[1] for _ in [1]*N for a in [list(map(int,input().split()))]],[]))[K-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
list = []
for i in range(0, N):
    a, b = map(int, input().split())
    for j in range(0, b):
        list.append(a)
list.sort()
print(list[K-1])

Submission status: Time Limit Exceeded

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

nlist = []
for i in range(N):
    a, b = map(int, input().split())
    if len(nlist) == 0:
        nlist.append((a, b))
    else:
        for i, (na, nb) in enumerate(nlist):
            if a <= na:
                nlist.insert(i, (a, b))
                break
            elif i == len(nlist) - 1:
                nlist.insert(i + 1, (a, b))
                break

cur_pos = 0
for a, b in nlist:
    cur_pos += b
    if cur_pos >= K:
        print(a)
        break

Submission status: Time Limit Exceeded

Solution code:

N, K = map(int, input().split())

lst = []

for _ in range(N):
    a, b = map(int, input().split())
    for _ in range(b):
        lst.append(a)

lst.sort()

print(lst[K-1])

Submission status: Time Limit Exceeded

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

array = []
n, k  = map(int, raw_input().split())

for i in range(n):
	a, b  = map(int, raw_input().split())
	for i in range(b):
		array.append(a)

array.sort()
print(array[k - 1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
import numpy as np
N, K = map(int, raw_input().split())
R = []
for i in xrange(N):
    ia, ib = map(int, raw_input().split())
    R.extend(np.ones(ib) * ia)

print int(sorted(R)[K-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(x) for x in input().split()]
Array = list()
a = 0
b = 0
for i in range(N):
	a, b = [int(x) for x in input().split()]
	Array.extend([a]*b)
	if len(Array) > K:
		Array.sort()
		Array = Array[:K]
	
print(Array[K - 1])

Submission status: Time Limit Exceeded

Solution code:
NK = list(map(int,input().split()))
AB = []
for _ in range(NK[0]):
    I = list(map(int, input().split()))
    for _ in range(I[1]):
        AB.append(I[0])
print(sorted(AB)[NK[1]-1])

Submission status: Time Limit Exceeded

Solution code:
nums = [int(x) for x in input().split()]
N = nums[0]
K = nums[1]
arr = []
for i in range(N):
	nums = [int(x) for x in input().split()]
	for j in range(nums[1]):
		arr.append(nums[0])
arr.sort()
print(arr[K-1])

Submission status: Time Limit Exceeded

Solution code:
def C(_mid):
    if _mid <= target_list[K - 1]:
        return True
    else:
        return False


N, K = list(map(int, input().split()))
target_list = []
for i in range(N):
    a, b = list(map(int, input().split()))
    for j in range(b):
        target_list.append(a)

target_list.sort()

lb = 1
ub = 100000
while ub - lb > 1:
    # print(str(lb) + " " + str(ub))
    mid = int((lb + ub) / 2)
    if C(mid):
        lb = mid
    else:
        ub = mid

print(lb)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
A=[]
C=[]
for i in range(N):
    a,b=map(int,input().split())
    T=[a,b]
    A.append(T)
A.sort()    
for i in range(N):
    if len(C)>K:
        break
    for j in range(A[i][1]):
        C.append(A[i][0])
        if len(C)>K:
            break      
print(C[K-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
c = []
for i in range(N):
	c.append(input().split())
	
d = []
e = []

for j in range(N):
	e.append(c[j][0])
	e = e * int(c[j][1])
	d = d + e
	e = []

d.sort()

print(d[K-1])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n,k = input().split()
n = int(n)
k = int(k)
l = list()
for i in range(n):
    a, b = input().split()
    for j in range(int(b)):
        l.append(int(a))

l.sort()
print(l[k-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(x) for x in input().split()]
Array = list()
a = 0
b = 0
for i in range(N):
	a, b = [int(x) for x in input().split()]
	Array.extend([a]*b)

Array.sort()
print(Array[K - 1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
import numpy as np
N, K = map(int, raw_input().split())
R = np.array([])
for i in xrange(N):
    ia, ib = map(int, raw_input().split())
    R = np.append(R, np.ones(ib) * ia)

print int(np.sort(R)[K-1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

def flatten(nested_list):
    return [e for inner_list in nested_list for e in inner_list]

N, K = map(int, raw_input().split())

a = [0] * N
b = [0] * N
ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, raw_input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

ans = flatten([[a] * b for a, b in ab])
print ans[K - 1]

Submission status: Time Limit Exceeded

Solution code:
import sys
N,K=map(int, input().split())
p=[]
for i in range (0,N):
  r=list(map(int, input().split() )) 
  p.append(r)
p.sort()
q=[]
for i in range(0,N):
  q+=[p[i][0]]*p[i][1]
  if len(q)>K:
    print(q[K-1])
    sys.exit()

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int,input().split(" "))
l = []
for i in range(n):
    a, b = map(int, input().split(" "))
    l.extend([a] * b)
l.sort()
print(l[k - 1])

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
A=[]
B=[]
C=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
for i in range(N):
    if len(C)>K:
            break
    for j in range(B[i]):
        C.append(A[i])
        C.sort()
        if len(C)>K:
            break
print(C[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,raw_input().split())
c=[]
for i in range(N):
	a,b=map(int,raw_input().split())
	c+=[a]*b

c.sort()
print c[K-1]

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int, input().split())
p=[]
for i in range (0,N):
  r=list(map(int, input().split() )) 
  p.append(r)
p.sort()
q=[]
for i in range(0,N):
  q+=[p[i][0]]*p[i][1]
print(q[K-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
c = []
for i in range(N):
	c.append(input().split())
	
d = []
k = 0

for j in range(N):
	while k < int(c[j][1]):
		d.append(c[j][0])
		k += 1
	k = 0

d.sort()

print(d[K-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = [int(x) for x in input().split(' ')]
exist = []
storage = [0 for x in range(10 ** 5+1)]
for i in range(n):
    a, b = [int(x) for x in input().split(' ')]
    storage[a] += b
    if a not in exist:
        exist.append(a)
exist.sort()
sum = 0
for i in exist:
    sum += storage[i]
    if sum >= k:
        print(i)
        break
    else:
        continue

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
A=[]
B=[]
C=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
for i in range(N):
    for j in range(B[i]):
        C.append(A[i])
C.sort()
print(C[K-1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, raw_input().split())

ans = []
for _ in range(N):
    a, b = map(int, raw_input().split())
    ans = ans + [a] * b

ans.sort()
print ans[K - 1]

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
seq = []
for i in range(N):
    a, b = map(int, input().split())
    for j in range(b):
        seq.append(a)

seq.sort()
print(seq[K-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split()))
big_array = list()

for _ in range(N):
    a, b = list(map(int, input().split()))
    big_array += [a]*b

big_array.sort()

print(big_array[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
tmp=[]
for i in range(N):
    a_i,b_i=map(int,input().split())
    tmp += [a_i]*b_i

tmp.sort()
print(tmp[K-1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

N, K = map(int, input().split())

A = []
for i in range(N):
    a, b = map(int, input().split())
    A += [a] * b

A.sort()
print(A[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K = [int(x) for x in input().split()]
arr=[]
for i in range(N):
    a,b = [int(x) for x in input().split()]
    arr = arr + [a]*b
arr.sort()
print(arr[K-1])

Submission status: Accepted

Solution code:
#n = int(input())
n, k = map(int, input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
dic = {}
for i in range(n):
    a, b = map(int, input().split())
    dic[a] = dic.get(a, 0)+b

l = sorted(dic.items())

for a, b in l:
    if k <= b:
        ans = a
        break
    k -= b
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
query = sorted([tuple(map(int, input().split())) for _ in range(n)])

cnt = 0
i = 0
while cnt < k:
    a, b = query[i]
    cnt += b
    i += 1
print(a)

Submission status: Accepted

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

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])


total = 0
for pair in ab:
    total += pair[1]
    if total >= K:
        print(pair[0])
        break

Submission status: Accepted

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

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

j = 0
index = 0
while j < K:
    j += ab[index][1]
    if j < K:
        index += 1

print(ab[index][0])

Submission status: Accepted

Solution code:
xx = []
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
xx = sorted(ab, key= lambda x:x[0])

ans = 0
for i in range(n):
  ans += xx[i][1]
  if ans >=  k:
    print(xx[i][0])
    break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 28 01:21:16 2020

@author: liang
"""

#バケツソートO(n)
N, K = map(int,input().split())
num = [0]*(10**5+1)
for i in range(N):
    a, b = map(int,input().split())
    num[a] += b

tmp = 0
for i in range(10**5+ 1):
    tmp += num[i]
    if tmp >= K:
        print(i)
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 28 01:14:47 2020

@author: liang
"""

N, K = map(int,input().split())
A = list()
for i in range(N):
    a, b = map(int,input().split())
    A.append((a,b))
A.sort(key= lambda x:x[0])

tmp = 0
for i in range(N):
    a, b = A[i]
    tmp += b
    if tmp >= K:
        print(a)
        break

Submission status: Accepted

Solution code:
from collections import defaultdict
def main():
  N, K = map(int,input().split())
  D = defaultdict(int)
  for _ in range(N):
    a, b = map(int,input().split())
    D[a]+=b
  D = sorted(D.items())
  ans, total = D[0]
  for i in range(1,len(D)):
    if K <= total:
      print(ans)
      return
    else:
      c, d = D[i]
      ans = c
      total+=d
  print(ans)
  return

main()

Submission status: Accepted

Solution code:
li = [0]*(10**5+10)
n,k = map(int, input().split())
for i in range(n):
    a,b = map(int, input().split())
    li[a] += b
cnt = 0
ans = 0
for i in range(10**5+10):
    cnt += li[i]
    ans = i
    if cnt >= k:
        break
print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
count=[0]*(100001)
for i in range(1,N+1) :
  a,b=map(int,input().split())
  count[a]+=b
for i in range(1,100001) :
  if K<=count[i] :
    print(i)
    break
  K-=count[i]

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()

def slv():
    cnt = 0
    for i in range(n):
        cnt += ab[i][1]
        if cnt >= k:
            return print(ab[i][0])

slv()

Submission status: Accepted

Solution code:
from collections import defaultdict
n,k = map(int, input().split())
ans = 0
al = []
d = defaultdict(int)
for i in range(n):
  a,b = map(int, input().split())
  al.append(a)
  d[a] += b
al = list(set(al))  
al.sort()
for i in al:
  if k > d[i]:
    k -= d[i]
  else:
    print(i)
    break

Submission status: Accepted

Solution code:
import itertools
n,k = map(int,input().split())

ab = [0]*n

for i in range(n):
  ab[i] = input().split()
a = []
b = []
for i in range(n):
  tmp1 = int(ab[i][0])
  tmp2 = int(ab[i][1])
  a.append(tmp1)
  b.append(tmp2)
ab = zip(a,b)
ab = sorted(ab)
a,b = zip(*ab)

s = 0
for i in range(n):
  s += int(b[i])
  if s >= k:
    print(int(ab[i][0]))
    exit()

Submission status: Accepted

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

nums = [0]*(10**5+1)

for i in range(n):
    a, b = map(int,input().split())
    nums[a] += b
    
now = 0
for i,n in enumerate(nums):
    now += n
    if now >= k:
        print(i)
        break

Submission status: Accepted

Solution code:
n, k = map(int, input().split(" "))
a = sorted([list(map(int, input().split(" "))) for i in range(n)])
count = 0
for x, y in a:
  count += y
  if k <= count:
    print(x)
    break
else:
  print("None")

Submission status: Accepted

Solution code:
#95 C - Big Array
N,K = map(int,input().split())
lis = []
for _ in range(N):
    a,b = map(int,input().split())
    lis.append((a,b))

lis = sorted(lis,reverse = False)

cnt = 0
num = 0
for a,b in lis:
    cnt += b
    num = a
    if cnt >= K:
        break
print(num)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
a = []
b = []
Sum = 0
for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
s = [*range(len(a))]
sort_s = sorted(s, key = lambda i: a[i])
sort_a = [a[i] for i in sort_s]
sort_b = [b[i] for i in sort_s]
for i in range(N):
    Sum += sort_b[i]
    if Sum >= K:
        print(sort_a[i])
        break

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
cnt=0
P=[]
for i in range(N):
    a,b=map(int,input().split())
    P.append((a,b))

P=sorted(P)
for i in range(N):
    cnt+=P[i][1]
    if cnt>=K:
        print(P[i][0])
        break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort()

num_sum = 0

for a, b in ab:
    num_sum += b
    if num_sum >= k:
        print(a)
        exit()

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()

cnt=0
for a,b in ab:
  cnt+=b
  if cnt >= k:
    print(a)
    exit()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
total = 0
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
for a, b in ab:
    total += b
    if total >= k:
        print(a)
        break

Submission status: Accepted

Solution code:
from xml.dom import minidom


n, k = map(int, input().split())

AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort()

now = -1
idx = 0
while k > 0:
    if idx >= n:
        break
    a, b = AB[idx]
    k -= b
    now = a
    idx += 1
print(now)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
s=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    s[a-1]+=b
i=0
while k>0:
    k-=s[i]
    i+=1
print(i)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
res=k
ab.sort()
for i in range(n):
  res-=ab[i][1]
  if res<=0:
    print(ab[i][0])
    exit()

Submission status: Accepted

Solution code:
from collections import Counter

n, k = map(int, input().split())

d = Counter()
for _ in range(n):
    a, b = map(int, input().split())
    d[a] += b

x = sorted(d.items(), key=lambda x: x[0])
cnt = 0
for a, b in x:
    cnt += b
    if cnt >= k:
        print(a)
        exit()

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
    N, K = map(int, input().split())
    d = defaultdict(int)
    for _ in range(N):
        a, b = map(int, input().split())
        d[a] += b
    total = 0
    for v, freq in sorted(d.items()):
        total += freq
        if total >= K:
            print(v)
            exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
bucket = [0] * 10 ** 5
for i in range(n):
    a, b = map(int, input().split())
    bucket[a - 1] += b

sum_b = 0
for i in range(len(bucket)):
    sum_b += bucket[i]
    if sum_b >= k:
        print(i + 1)
        break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sum_b = 0
ab_list = []

for i in range(n):
    ab_list.append(list(map(int, input().split())))

ab_list.sort()
for i in range(n):
    a, b = ab_list[i]
    sum_b += b
    if sum_b >= k:
        print(a)
        break

Submission status: Accepted

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

command = [list(map(int,input().split())) for i in range(N)]

command.sort()

ind = 0
for i in range(N):
    if ind + command[i][1]>=K:
        print(command[i][0])
        exit()
    else:
        ind += command[i][1]

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))

a = sorted(a, key = lambda x:x[0])

x = 0
for i in a:
	x += i[1]
	if x >= k:
		break
print(i[0])

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(N)]

ls.sort(key=lambda x: x[0])
s = 0

for i in range(N):
  s += ls[i][1]
  if s >= K: break
    
print(ls[i][0])

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, k = LI()
    lst = []

    for _ in range(n):
        a, b = LI()
        lst.append((a,b))
    
    lst.sort(key=lambda x: x[0])
    taken = 0
    ans = 0

    for i in range(n):
        ans = lst[i][0]
        taken += lst[i][1]

        if taken >= k:
            break

    print(ans)
main()

Submission status: Accepted

Solution code:
# C - Big Array
def main():
    n, k = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    ab.sort()

    i = 0

    while k > 0:
        k -= ab[i][1]
        i += 1
    else:
        print(ab[i-1][0])

if __name__ ==  "__main__":
    main()

Submission status: Accepted

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

lst = [list(map(int, input().split())) for _ in range(N)]
lst.sort(key=lambda x: x[0])
s = 0
for i in range(N):
	s += lst[i][1]
	if s >= K: break
print(lst[i][0])

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
ab=list(list(map(int,input().split())) for _ in range(N))
ab.sort()

i=0
while K>0:
    K-=ab[i][1]
    i+=1
print(ab[i-1][0])

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
x=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    x[a]+=b
ans=0
for i in range(10**5+1):
    ans+=x[i]
    if ans>=k:
        print(i)
        break