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: Accepted

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

ab.sort()

ans = 0
j = k
for i in ab:
    ans = i[0]
    j -= i[1]
    if j<=0:
        break

print(ans)

Submission status: Accepted

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

for a, b in AB:
    k -= b
    if k <= 0:
        print(a)
        break

Submission status: Accepted

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

input_dic = {}
for line in input_lines:
    input_dic[line[0]] = input_dic.get(line[0],0)+line[1]

for key in sorted(input_dic.keys()):
    if input_dic[key]>=k:
        print(key)
        break
    else:
        k-=input_dic[key]

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
d = {}
for i in range(n):
  a,b = map(int,input().split())
  if a in d:
    d[a] += b
  else:
    d[a] = b
cnt = 0
d_key = sorted(d)
for i in d_key:
  cnt += d[i]
  if cnt >= k:
    print(i)
    break

Submission status: Accepted

Solution code:
from collections import Counter
import sys


N, K = map(int, input().split())
C = Counter()
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    C[a] += b

keys = list(C.keys())
keys.sort()
cnt = 0
for k in keys:
    cnt += C[k]
    if cnt >= K:
        break
print(k)

Submission status: Accepted

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

sub = 0
ab.sort()
for i in range(n):
    sub += ab[i][1]
    if sub >= k:
        print(ab[i][0])
        break

Submission status: Accepted

Solution code:
class Number:
    def __init__(self,number,qty):
        self.qty=qty
        self.number=number

n,k=map(int,input().split())
listn=[]
for a in range(n):
    b,c=map(int,input().split())
    listn.append(Number(b,c))
listn.sort(key=lambda x:x.number)
count=k
for a in listn:
    if a.qty>=count:
        print(a.number)
        break
    else:
        count-=a.qty

Submission status: Accepted

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


def main():
    N, K = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]
    AB.sort()

    for a, b in AB:
        K -= b
        if K <= 0:
            break

    print(a)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np

n, k = map(int, input().split())
a = np.array([list(map(int, input().split())) for i in range(n)])

b = a[np.argsort(a[:,0])]
c = np.cumsum(b[:,1])
d = np.min(np.where(k <= c))
ans = b[d, 0]
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x: x[0])
count = 0
for i in range(n):
    a, b = ab[i][0], ab[i][1]
    count += b
    if count >= k:
        print(a)
        exit()

Submission status: Accepted

Solution code:
import sys
N, K = map(int,input().split())
hairetu = []
for _ in range(N): hairetu.append(list(map(int,input().split())))
hairetu.sort()
cnt = 0
for i in range(N):
  cnt += hairetu[i][1]
  if K <= cnt:
    print(hairetu[i][0])
    sys.exit()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
from operator import itemgetter
ab.sort(key=itemgetter(0))
s = [0] * (N + 1)
for i in range(N):
    s[i + 1] = s[i] + ab[i][1]
    if s[i + 1] >= K:
        print(ab[i][0])
        break

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split(' ')))
abn = [None] * n
for i in range(n):
    abn[i] = list(map(int, input().split(' ')))

abn = sorted(abn, key=lambda ab: ab[0])

ans = -1
temp = 0
i = 0
while True:
    if temp + abn[i][1] >= k:
        ans = abn[i][0]
        break
    temp += abn[i][1]
    i += 1
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
li = []
for i in range(n):
    a,b = map(int,input().split())
    li.append((a,b))
li.sort(key = lambda x:x[0])
count = 0

for i in range(10**5):
    count += li[i][1]
    if count >= k:
        print(li[i][0])
        break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
number = [[0,0] for i in range(n)]
for i in range(n):
    number[i] = list(map(int, input().split()))
number.sort(key=lambda x:(x[0],x[1]))
count = 0
result = 0
for el in number:
    count += el[1]
    if count >= k:
        result = el[0]
        break
print(result)

Submission status: Accepted

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

a=[]
for i in range(n):
    ai,bi=map(int,input().split())
    a.append([ai,bi])
    
a.sort()

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
count = 0
AB.sort()
for a,b in AB:
  count += b
  if count >= K:
    print(a)
    exit()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
l=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    l[a-1]+=b
m=0
for i in range(10**5):
    if m+l[i]>=k:print(i+1);break
    else: m+=l[i]

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.append([a, b])
a_list.sort(key=lambda x: x[0])
for i in range(n):
	k -= a_list[i][1]
	if k <= 0:
		print(a_list[i][0])
		break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
li=[]
for i in range(n):
    a, b = map(int, input().split())
    li.append([a,b])
li=sorted(li, key=lambda x: x[0])
for i in range(n):
    k -= li[i][1]
    if k <= 0:
        print(li[i][0])
        break

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()
ab = nan(n)
ab.sort()

ans = 0
cur = 0
for i in range(n):
    a, b = ab[i]
    cur += b
    if cur >= k:
        print(a)
        break

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
ins=[list(map(int,input().split())) for _ in range(N)]
#print(ins)
ins.sort(key=lambda x:x[0])
num=0
for i in range(N):
    num=num+ins[i][1]
    if num-ins[i][1]<K<=num:
        print(ins[i][0])
        break

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = [0]*(10**5+1)

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

total = 0
for i, n in enumerate(l):
    total += n
    if total>=K:
        print(i)
        break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ab=[]
for _ in range(N):
    ab.append(tuple(map(int, input().split())))
ab=sorted(ab, key=lambda x:x[0])
#print(ab)
accum=[0]
for i in range(len(ab)):
    accum.append(accum[i]+ab[i][1])
#print(accum)
for i in range(len(ab)):
    #print(accum[i], accum[i+1])
    if accum[i] < K <= accum[i+1]:
        print(ab[i][0])
        break

Submission status: Accepted

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

a.sort()
for i in range(n):
  k -= a[i][1]
  if k <= 0:
    print(a[i][0])
    break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
freq = dict()
for i in range(n):
  a, b = map(int, input().split())
  if freq.get(a): freq[a] += b
  else: freq[a] = b
f_asc = sorted(freq.items(), key=lambda x: x[0])
idx = 0
for kv in f_asc:
  idx += kv[1]
  if idx >= k:
    print(kv[0])
    break

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
x = sorted([list(map(int,input().split())) for i in range(n)])
for i,j in x:
    k -= j
    if k<=0:
        print(i)
        exit()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
x = sorted([list(map(int,input().split())) for i in range(n)])
for i,j in x:
    if k-j<=0:
        print(i)
        exit()
    else:
        k-=j

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
num =  [0] * 10**5
for i in range(n):
  a, b = map(int, input().split())
  num[a-1] += b
wa =  0
wa_b = 0
for i in range(len(num)):
  if num[i] == 0:
    pass
  else:
    wa += num[i]
    if wa_b < k and k <= wa:
      print(i+1)
      wa_b = wa
    else:
      wa_b = wa

Submission status: Accepted

Solution code:
n, k = (int(x) for x in input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ans= 0
ab = sorted(ab, key=lambda x: x[0])

for i,j in ab:
    ans+=j
    if k<=ans:
        print(i)
        break

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
cnt = [0]*100001
S = set()
for i in range(N):
  a, b = map(int, input().split())
  cnt[a-1] += b
  S.add(a)

acc = 0
for s in sorted(S):
  acc += cnt[s-1]
  if acc >= K:
    print(s)
    break

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
num = [0] * 100000
for i in range(n):
  c,d = map(int,input().split())
  num[c-1] += d
sum = 0
for i in range(100000):
  sum += num[i]
  if sum >= k:
    print(i + 1)
    exit()

Submission status: Accepted

Solution code:

# input = sys.stdin.readline

def resolve():
    N, K = map(int, input().split())
    L = [0] * (10 ** 5 + 1)
    for i in range(N):
        a, b = map(int, input().split())
        L[a] += b

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


resolve()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
l=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    l[a-1]+=b
s=0
for i in range(10**5):
    if s+l[i]>=k:print(i+1);break
    else: s+=l[i]

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import heapq

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def main():
    n, k = map(int, input().split())
    ary = []
    heapq.heapify(ary)
    for a, b in readlines(n):
        heapq.heappush(ary, (a, b))

    while True:
        a, b = heapq.heappop(ary)
        k -= b
        if k <= 0:
            print(a)
            return

main()

Submission status: Accepted

Solution code:
import numpy as np

N,K = [int(i) for i in input().split()]

ab = np.ones([N,2])

for i in range(N):
    ab[i,0], ab[i,1] = [int(i) for i in input().split()]

ab_sort = ab[np.argsort(ab[:,0])]

cout = 0

for i in range(N):
    cout += ab_sort[i,1]
    if cout >= K:
        print(int(ab_sort[i,0]))
        break

Submission status: Accepted

Solution code:
#61c
#import random #テスト用

N,K = map(int, input().split())#N,K<=10**5　#Nのループで考えないとTLEしそう
#N = 100000 #test

a_b_dict = dict()

#b_sum = 0 #test

for i in range(N):
    a,b = map(int, input().split())
    #a = random.randint(1, 100000) #test
    #b = random.randint(1, 100000) #test
    
    if a not in a_b_dict:
        a_b_dict[a] = 0
    
    a_b_dict[a] += b
    
    #b_sum += b #test
    
a_b_dict_sorted = sorted(a_b_dict.items(), key=lambda x:x[0])

#K = random.randint(1, b_sum)

position = 0
for ab in a_b_dict_sorted:
    b = ab[1]
    position += b
    
    if position >= K:
        print(ab[0])
        break

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

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

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

Submission status: Accepted

Solution code:
import math
import collections
from operator import mul
from functools import reduce


n,k=map(int,input().split())
a=[(0,0)]*n
for i in range(n):
  a[i]=tuple(map(int,input().split()))

a=sorted(a)
for ai in a:
    k-=ai[1]
    if k<=0:
        print(ai[0])
        exit()

Submission status: Accepted

Solution code:
from operator import itemgetter
n,k = (map(int,input().split()))
a = sorted([list(map(int,input().split())) for i in range(n)])
count = 0
for i in range(len(a)):
         count += a[i][1]
         if count >= k:
                  print(a[i][0])
                  exit()

Submission status: Accepted

Solution code:
N,K =map(int,input().rstrip().split())
ans = [0 for _ in range(10 ** 5 + 1)]
for i in range(N):
  a,b = map(int,input().rstrip().split())
  ans[a] += b
counter = 0
c2 = 0
while counter < K:
  c2  += 1
  counter += ans[c2]
print(c2)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[]
b=[]
for _ in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
#binary search for answer
lo=1
hi=max(a)
while lo<hi:
    md=(lo+hi)//2
    def chk(md):
        cnt=0
        for i in range(n):
            if a[i]<=md:
                cnt+=b[i]
        return cnt
    if chk(md)>=k:
        hi=md
    else:
        lo=md+1
print(lo)

Submission status: Accepted

Solution code:
n,k,*l=map(int,open(0).read().split())
for a,b in sorted(zip(l[::2],l[1::2])):
  k-=b
  if k<1:print(a);break

Submission status: Accepted

Solution code:
n,k,*l=map(int,open(0).read().split());c=0
for a,b in sorted(zip(l[::2],l[1::2])):
  c+=b
  if c>=k:print(a);break

Submission status: Accepted

Solution code:
f=lambda:map(int,input().split());n,k=f();c=0
for a,b in sorted(list(f())for _ in[0]*n):
  c+=b
  if c>=k:print(a);break

Submission status: Accepted

Solution code:
f=lambda:map(int,input().split());n,k=f();c=0
for a,b in sorted(list(f())for _ in range(n)):
  c+=b
  if c>=k:print(a);break

Submission status: Accepted

Solution code:
f=lambda:map(int,input().split())
n,k=f()
c=0
for a,b in sorted(list(f()) for _ in range(n)):
  c+=b
  if c>=k: print(a); break

Submission status: Accepted

Solution code:
f=lambda:map(int,input().split())
n,k=f()
d={}
for i in range(n):
  a,b=f()
  d[a]=d.get(a,0)+b
c=0
for a,b in sorted(d.items()):
  c+=b
  if c>=k: print(a); break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from operator import itemgetter

rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    ab = [list(map(int, rl().split())) for _ in range(N)]
    ab.sort(key=itemgetter(0))
    
    cnt = 0
    for a, b in ab:
        cnt += b
        if K <= cnt:
            print(a)
            exit()


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d = {}
for _ in range(n):
    a, b = map(int, input().split())
    d[a] = d.get(a, 0) + b

cnt = 0
for i, v in sorted(d.items(), key=lambda x: x[0]):
    cnt += v
    if cnt >= k:
        print(i)
        break

Submission status: Accepted

Solution code:
#061_C
n, k = map(int, input().split())
pair = []
for _ in range(n):
    a, b = map(int, input().split())
    pair.append((a, b))
pair.sort()

tmp = 0
for a, b  in pair:
    tmp += b
    if k <= tmp:
        print(a)
        break

Submission status: Accepted

Solution code:
from collections import defaultdict
n,k=map(int,input().split())
d=defaultdict(int)
for i in range(n):
  a,b=map(int,input().split())
  d[a]+=b
l=[]
for u,v in d.items():
  l.append((u,v))
l.sort(key=lambda x:x[0])
i=0
while k-l[i][1]>0:
  k-=l[i][1]
  i+=1
print(l[i][0])

Submission status: Accepted

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

A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

C = zip(A, B)
C = sorted(C)
A, B = zip(*C)
for i in range(n):
    a = A[i]
    b = B[i]
    k -= b
    if k <= 0:
        print(a)
        break

Submission status: Accepted

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

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

Submission status: Accepted

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

count = [0] * (10 ** 5 + 2)
for a, b in query:
    count[a] += b

for i, c in enumerate(count):
    k -= c
    if k <= 0:
        print(i)
        exit()

Submission status: Accepted

Solution code:
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    n,k = map(int,input().split())
    a = []
    for i in range(n):
        a.append(list(map(int,input().split())))
    a.sort()
    cnt = 0
    for i in range(n):
        cnt += a[i][1]
        if cnt>=k:
            print(a[i][0])
            break
    return

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ab = [[int(i) for i in input().split()] for _ in range(n)]
ab = sorted(ab, key=lambda x:x[0])
k_ = 0
for a, b in ab:
    k_ += b
    if k_ >= 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(key=lambda x: x[0])
index = 0
for i in range(n):
  index += ab[i][1]
  if index >= k:
    ans = ab[i][0]
    break

print(ans)

Submission status: Accepted

Solution code:
n,k = [int(x) for x in input().split()]
d = {}
for _ in range(n):
    a = [int(x) for x in input().split()]
    if a[0] in d.keys():
        d[a[0]] += a[1]
    else:
        d[a[0]] = a[1]


for i in sorted(d.keys()):
    k -= d[i]
    if k <= 0:
        print(i)
        break

Submission status: Accepted

Solution code:
import sys
N, K = map(int, input().split())
arr = [0 for _ in range(10**5 + 1)]
su = 0
ans = 0

for n in range(N):
  a, b = map(int, input().split())
  arr[a] += b
  
for i in range(1, 10**5+1):
  su += arr[i]
  if su >= K:
    ans = i
    break
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = sorted([tuple(map(int, input().split()))for _ in range(N)], key=lambda x:x[0])
c = 0
for i in l:
  c += i[1]
  if c >= K:
    print(i[0])
    break

Submission status: Accepted

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

ab = [tuple(map(int, input().split())) for _ in range(N)]

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

cnt = 0

for v in ab:
    cnt += v[1]

    if cnt >= K:
        print(v[0])
        exit(0)

Submission status: Accepted

Solution code:
from operator import itemgetter
N, K = map(int, input().split())
ab = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append((a,b))
ab.sort(key=itemgetter(0))

R = [0]*(N+1)
for i in range(1,N+1):
    R[i] += R[i-1] + ab[i-1][1]

for i in range(1,N+1):
    if R[i-1]<K<=R[i]:
        print(ab[i-1][0])

Submission status: Accepted

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

ab.sort()

cusum = [0]*(n+1)
for i in range(n):
    cusum[i+1] = cusum[i] + ab[i][1]

index = bisect.bisect_left(cusum, k) - 1
print(ab[0 if index < 0 else index][0])

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a=[0]*N
b=[0]*N
c=[0]*N
for i in range(N):
  a[i],b[i]= map(int,input().split())
  c[i]=(a[i],b[i])
  
c.sort(key=lambda x: x[0])
cnt=0

for j in range(N):
  cnt += c[j][1]
  if cnt>=K:
    print(c[j][0])
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
mat = [list(map(int, input().split())) for _ in range(n)]
mat.sort(key=lambda x: x[0])
for a, b in mat:
    k -= b
    if k <= 0:
        print(a)
        exit()

Submission status: Accepted

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

cnt = 0
d = {}
for _ in range(N):
    a, b = map(int, input().split())
    if a in d:
        d[a] += b
    else:
        d[a] = b

sorted_d = sorted(d.items(), key=lambda x: x[0])
cnt = 0
for k, v in sorted_d:
    cnt += v
    if cnt >= K:
        print(k)
        break

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = sorted([[int(i) for i in input().split()] for M in range(N)])

for i in range(N):
    a, b = l[i]
    if K>b:
        K-=b
    else:
        print(a)
        exit()

Submission status: Accepted

Solution code:
N, M = map(int,input().split()) 
P = [list(map(int,input().split())) for i in range(N)]
P.sort()
a = 0
for i in range(N):
    if M <= P[i][1]:
        break
    M = M-P[i][1]
    a += 1


print(P[a][0])

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
Array={}
for n in range(0,N):
    a,b=map(int,input().split())
    if a in Array:
        Array[a]+=b
    else:
        Array[a]=b
numbers=sorted(list(Array.keys()))
n=0
k=0
while True:
    k+=Array[numbers[n]]
    if k>=K:
        break
    n+=1
print(numbers[n])

Submission status: Accepted

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

dic = {}
for i in range(n):
    a,b = map(int,input().split())
    try:
        dic[a] += b
    except:
        dic[a] = b

#print(dic)
dic = sorted(dic.items(),key=lambda x:x[0])

for a,b in dic:
    if b-k >=0:
        print(a)
        exit()
    else:
        k -= b

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
ab=sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x: x[0])

for i in range(N):
    a,b=ab[i]
    if K>b:
        K-=b
    else:
        print(a)
        exit()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]
AB.sort()
cnt=0
for i , j in AB:
    cnt+=j
    if k<=cnt:
        print(i)
        exit()

Submission status: Accepted

Solution code:
n,k = map(int, input().split( ))
ins = [tuple(map(int, input().split( ))) for _ in range(n)]
ins.sort()
cnt = 0
for i in range(n):
    cnt += ins[i][1]
    if cnt >= k:
        print(ins[i][0])
        exit()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
c = 0
A = []
for i in range(n):
    A.append(list(map(int, input().split())))
A = sorted(A)
for i in A:
    if c + i[1] >= k:
        print(i[0])
        exit()
    else:
        c += i[1]

Submission status: Accepted

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

for _ in range(n):
    a , b = map(int,input().split())
    dic.setdefault(a , 0)
    dic[a] += b
    
sdic = sorted(dic.items(), key = lambda x : x[0])

for i in range(n):
    k -= sdic[i][1]
    
    if k <= 0:
        print(sdic[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(key=lambda x:x[0])
cnt=0
for i in range(N):
    cnt+=ab[i][1]
    if cnt>=K:
        print(ab[i][0])
        exit()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    d = defaultdict(int)
    for ai, bi in zip(a, b):
        d[ai] += bi
    for k, v in sorted(d.items()):
        K -= v
        if K <= 0:
            print(k)
            return
    assert False


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
li = sorted([tuple(map(int, input().split())) for _ in range(N)])
cnt = 0
for a, b in li:
    cnt += b
    if cnt >= K:
        print(a)
        break

Submission status: Accepted

Solution code:
from collections import defaultdict
N,K = map(int,input().split())
d = defaultdict(int)
for _ in range(N):
  a,b = map(int,input().split())
  d[a] += b
  
for k,v in sorted(d.items()):
  if v >= K:
    print(k)
    exit()
  K -= v

Submission status: Accepted

Solution code:
def main():
  n,k=map(int,input().split())
  ab=sorted([list(map(int,input().split())) for _ in [0]*n],key=lambda x:x[0])
  count=0
  for i in range(n):
    count+=ab[i][1]
    if count>=k:
      print(ab[i][0])
      exit()  
if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
a = [[0]*2 for i in range(N)]
for i in range(N):
    a[i][0],a[i][1] =  map(int,input().split())

a.sort()

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
li = []
for i in range(N):
    li.append(list(map(int, input().split())))
li.sort()
cnt = 0
for x in li:
    cnt+=x[1]
    if cnt >= K:
        print(x[0])
        break

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
d=dict()
for i in range(n):
  a,b=map(int,input().split())
  if a not in d:
    d[a]=b
  else:
    d[a]+=b
d=list(d.items())
d.sort()
cnt=0
for i in range(n):
  if cnt+d[i][1]<k:
    cnt+=d[i][1]
  else:
    print(d[i][0])
    exit()

Submission status: Accepted

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

c = [0 for _ in range(10**5+1)]

for i in range(N) :
    c[a[i]] += b[i]

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

Submission status: Accepted

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

for _ in range(N):
	a, b = map(int, input().split())
	lst.append([a, b])
	
lst.sort(key = lambda x : -x[0])

tot = 0
while True:
	val, num = lst.pop()
	tot += num
	if tot >= K:
		print(val)
		break

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    ab=[[0,0] for _ in range(N)]
    for i in range(N):
        ab[i][0],ab[i][1]=MI()
        
    ab.sort()
    
    ans=0
    temp=0
    for i in range(N):
        temp+=ab[i][1]
        if  temp>=K:
            ans=ab[i][0]
            break
        
    print(ans)
        

main()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
listA=[0]*10**5
for z in range(N):
    a,b=map(int,input().split())
    listA[a-1]+=b
count=0
y=0
while count<=10**5-1:
    y+=listA[count]
    if y>=K:
        print(count+1)
        break
    else:
        count+=1

Submission status: Accepted

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

    d[a] += b
for i in range(len(d)):
    k -= d[i]
    if k <= 0:
        print(i)
        break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ab = [0] * n
cnt = [0] * 100001
for i in range(n):
    a, b = map(int, input().split())
    cnt[a] += b
ans = 0
for num in range(1, 100002):
    ans += cnt[num]
    if ans >= k:
        print(num)
        break

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
ab = sorted([list(map(int,input().split())) for _ in range(n)])
i = 0
c = ab[0][1]
while c < k:
    i += 1
    c += ab[i][1]
print(ab[i][0])

Submission status: Accepted

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

ab.sort()
count = 0
for i in range(N):
    count+=ab[i][1]
    if count >= K:
        print(ab[i][0])
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

nums = []
for _ in range(n):
  ab = list(map(int, input().split()))
  nums.append(ab)
sn = sorted(nums)

i = 0
while k > 0:
  if sn[i][1] < k:
    k -= sn[i][1]
  else:
    print(sn[i][0])
    break
  i += 1

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


N, K = MI()
AB = [tuple(MI()) for _ in range(N)]
AB.sort()

cnt = 0
for a, b in AB:
    if K <= cnt + b:
        print(a)
        exit(0)
    cnt += b

Submission status: Accepted

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