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:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
N, K = map(int, input().split())
d = [0 for _ in range(10**5+1)]
for _ in range(N) :
  a, b = map(int, input().split())
  d[a] += b

s = 0
for i in range(len(d)) :
  s += d[i]
  if s >= K :
    print (i)
    exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N, K = map(int, input().split())

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

cnt = 0
prev = None
for a, b in sorted(num_cnt.items()):
    if cnt >= K:
        break
    cnt += b
    prev = a
print(prev)

Submission status: Accepted

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

ABn = sorted(ABn, key=lambda x: x[0])
crr = K
ans = 0
for i in range(N):
    crr -= ABn[i][1]
    if crr <= 0:
        ans = ABn[i][0]
        break

print(ans)

Submission status: Accepted

Solution code:
tmp0 = input().split()
n = int(tmp0[0])
k = int(tmp0[1])
a = []
b = []
for i in range(n):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))

arr = [0]*(10**5 + 1)
for i in range(n):
    arr[a[i]] += b[i]

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

Submission status: Accepted

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

x = [0 for _ in range(0, 100001)]

for i in range(n):
   a, b = map(int, input().split())
   x[a] += b

l = 0
for i in range(1, 100001):
   if (l < k and (l + x[i]) >= k ):
      print(i)
      exit()

   l += x[i]

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

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 main():
    N, K = LI()
    ops = []
    for _ in range(N):
        a, b = LI()
        ops.append((a, b))
    ops = sorted(ops, key=lambda x: x[0])
    for op in ops:
        a, b = op
        if K - b <= 0:
            ans = a
            break
        K -= b
    print(ans)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
score = {}
L = 0
Z = 0
for i in range(N):
  a,b = map(int,input().split())
  L += b
  if a in score:
    score[a] += b
  else:
    score[a] = b

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

for k,v in score_sorted:
  Z += v
  if K <= Z:
    print(k)
    break

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
B=[0]*(10**5+1)
for i in range(N):
  B[A[i][0]]+=A[i][1]

x=0
for i in range(10**5+1):
  x+=B[i]
  if x>=K:
    print(i)
    exit()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = [0] * n
b = [0] * n
sum = 0
arr = []
for i in range(n):
    a[i], b[i] = map(int, input().split())
arr_list = list(zip(a, b))
arr_list = sorted(arr_list)
# print(arr_list)
for i in range(n):
    sum += arr_list[i][1]
    # print(sum, arr_list[i])
    if sum >= k:
        answer = arr_list[i][0]
        break

print(answer)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
g=[]
for i in range(n):
    a,b=map(int,input().split())
    g.append([a,b])
g.sort()
i=0
while k>0:
    if k>g[i][1]:
        k-=g[i][1]
        i+=1
    else:
        ans=g[i][0]
        break
print(ans)

Submission status: Accepted

Solution code:
import sys
from itertools import accumulate
import bisect
n, k = [int(i) for i in sys.stdin.readline().split()]
ls = []
for i in range(n):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    ls.append([a, b])
ls.sort(key=lambda x:x[0])
a_ls, b_ls = zip(*ls)
res = [i for i in accumulate(b_ls)]
print(a_ls[bisect.bisect_left(res, k)])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ab=[[0,0] for i in range(n)]
for i in range(n):
  ab[i][0],ab[i][1]=map(int,input().split())
ab.sort()
y=0
for i in range(n):
  y+=ab[i][1]
  if y>=k:
    break
  
print(ab[i][0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import itemgetter
N,K = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(N)]
ls = sorted(ls,key=itemgetter(0))
len = 0
ans = 0
i = 0
while True:
    if len >= K:
        break
    ans = ls[i][0]
    len += ls[i][1]
    i += 1
print(ans)

Submission status: Accepted

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

for a, b in ab:
    K -= b
    if K <= 0:
        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 i in range(N):
    cnt += ab[i][1]
    if cnt >= K:
        ans = ab[i][0]
        break
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
AB = []
for i in range(N):
    AB.append(list(map(int,input().split())))
AB.sort(key=lambda x:x[0])
c = 0
for a,b in AB:
    c += b
    if c >= K:
        print(a)
        exit()

Submission status: Accepted

Solution code:
import sys
from heapq import *

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,k=MI()
    hp=[]
    for _ in range(n):
        a,b=MI()
        heappush(hp,[a,b])
    s=0
    while 1:
        a,b=heappop(hp)
        s+=b
        if s>=k:
            print(a)
            break
main()

Submission status: Accepted

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

ab.sort()

cnt=0
for i,j in ab:
  cnt+=j
  if cnt>=k:
    ans=i
    print(ans)
    exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N, K = map(int, input().split())
a = []
b = []
for i in range(N):
    a1, b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)
    
c = np.argsort(a)
ans = 0
for i in range(N):
    ans += b[c[i]]
    if ans >= K:
        print(a[c[i]])
        break

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ab = [tuple(map(int,input().split())) for _ in range(n)]
ab.sort(key = lambda x:x[0])
i = 0
j = 0
while i < k:
  i += ab[j][1]
  j += 1
  
print(ab[j-1][0])

Submission status: Accepted

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

ans = dict()
for i in range(N):
    a, b = map(int, input().split())
    if a in ans:
        ans[a] += b
    else:
        ans[a] = b
    
ans = sorted(ans.items(), key=lambda x:x[0])    
count = 0
for k, v in ans:
    count += v
    if count >= K:
        print(k)
        exit()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
lst = [[int(i) for i in input().split()] for i in range(n)]
nlst = sorted(lst,key= lambda x:x[0])
cnt = 0
 
for i in range(n):
    cnt += nlst[i][1]
    if cnt >= k:
        ans = nlst[i][0]
        break
    
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
    N,K = map(int,input().split())
    L = []
    for i in range(N):
        a,b = map(int,input().split())
        L.append((a,b))
    
    L.sort()
    for i in range(N):
        K -= L[i][1]
        if K <= 0:
            print(L[i][0])
            exit()
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    n,k=map(int,input().split())
    L=sorted([list(map(int,input().split())) for _ in range(n)])
    s=0
    for l in L:
        s += l[1]
        if k<=s:
            print(l[0])
            break
main()

Submission status: Accepted

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

total = 0
for a, b in AB:
  total += b
  if total >= 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])
counter=0
i=0
counter+=ab[i][1]
while counter<K:
  i+=1
  counter+=ab[i][1]
print(ab[i][0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
n, k = map(int, input().split())
d = deque()
for _ in range(n):
    a, b = map(int, input().split())
    d.append([a, b])
x = sorted(list(d))
for i in range(n):
    k -= x[i][1]
    if k < 1:
        print(x[i][0])
        break

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc061/tasks/abc061_c

# N回操作, K番目に大きい整数
N, K = map(int, input().split())


a_b_list = []
for i in range(N):
    # aをb個挿入する
    a, b = map(int, input().split())
    a_b_list.append([a, b])

a_b_list = sorted(a_b_list)

ans = 0
sum_elements = 0

for i in range(N):

    sum_elements += a_b_list[i][1]
    ans = a_b_list[i][0]
    
    if sum_elements >= K:
        print(ans)
        exit()

Submission status: Accepted

Solution code:
N,K = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for N in range(N)]
s = sorted(s)
ans_bool = True

for i in s:
  K = K - i[1]
  if (K <= 0) and (ans_bool):
    ans_bool = False
    print(i[0])

Submission status: Accepted

Solution code:
N,K =map(int,input().split())
result = [0]*(10**5+1)
for i in range(N):
  a,b = map(int,input().split())
  result[a] += b
count = 0
for j in range(len(result)):
  count += result[j]
  if count >= K:
    print(j)
    break

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
AB = [[i for i in map(int,input().split())] for j in range(N)]
sum = 0
AB.sort()

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

Submission status: Accepted

Solution code:
N , K = map(int,(input().split()))
 
sums = 0
nums = [0] * (10 ** 5 + 1) 
con = 0
ans = 0
 
for i in range(N):
  a,b = map(int,(input().split()))
  nums[a] += b
  
for i in range(len(nums)):
  con += nums[i]
  if K > con:
    continue
  elif K <= con:
    ans = i
    break

    
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
c = 0
AB = []
ABC = []
for _ in range(n):
    a, b = map(int, input().split())
    AB.append((a,b))

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

for i in range(n):
    c += AB[i][1]
    ABC.append((AB[i][0], AB[i][1], c))

for i in range(n):
    if k <= ABC[i][2]:
        ind = i
        break

print(ABC[ind][0])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
A = []
for _ in range(N):
    A.append([int(x) for x in input().split()])
A = sorted(A)
cnt = 0
for i in A:
    cnt += i[1]
    if cnt >= K:
        print(i[0])
        sys.exit()

Submission status: Accepted

Solution code:
a,b = [int(i) for i in input().split()]

temp = 0
l = sorted([[int(i) for i in input().split()] for _ in range(a)],key = lambda x: x[0])
for i in l:
    temp += i[1]
    if temp >= b:
        ans = i[0]
        break
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = []
b = []
for i in range(n):
    tmp1,tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)
ab =zip(a,b)
ab =sorted(ab)
a,b = zip(*ab)
counter = k
for i in range(n):
    counter -=b[i]
    if counter <= 0:
        print(a[i])
        break

Submission status: Accepted

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

lis = []
max_num = 0
for i in range(n):
    array = list(map(int, input().split()))
    if array[0] > max_num:
        max_num = array[0]
    lis.append(array)

num_list = [0] * max_num

for i, j in lis:
    num_list[i-1] += j

count = 0
for i in range(len(num_list)):
    count += num_list[i]
    if count >= k:
        print(i+1)
        exit()

Submission status: Accepted

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

abl = sorted(abl)
for a,b in abl:
    k -= b
    if k <= 0:
        print(a)
        import sys
        sys.exit()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

data=[]
n,k=map(int,input().split())
for i in range(n):
    a,b=map(int,input().split())
    data.append((a,b))
data.sort()
for di in data:
    if di[1]>=k:
        print(di[0])
        exit()
    else:
        k-=di[1]

Submission status: Accepted

Solution code:
N, k = map(int, input().split())  # N回の操作, K番目に小さいものを選ぶ
ans = []
for _ in range(N):
    ans.append(list(map(int, input().split())))
ans = sorted(ans, key=lambda x: x[0])
for value, amount in ans:
    if amount >= k:
        print(value)
        exit()
    else:
        k -= amount

Submission status: Accepted

Solution code:
import sys

n, k, *ab = map(int, sys.stdin.read().split())
ab = zip(*[iter(ab)] * 2)

def main():
    s = 0
    for a, b in sorted(ab):
        s += b
        if s >= k:
            return a

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

n, k, *ab = map(int, sys.stdin.read().split())
ab = zip(*[iter(ab)] * 2)

def main():
    cnt = defaultdict(int)
    for a, b in ab:
        cnt[a] += b
    
    s = 0
    for v, c in sorted(cnt.items()):
        s += c
        if s >= k:
            return v

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

Solution code:
import sys
bbn=1000000007
	
#+++++
		
def main():
	n, k= map(int, input().split())
	vv=[]
	for i in range(n):
		ai, bi = map(int, input().split())
		vv.append([ai,bi])
	vv.sort()
	for ai,bi in vv:
		k-= bi
		if k <= 0:
			return ai
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
num = 0
dicta = {}
for i in range(N):
    a,b = map(int,input().split())
    if a not in dicta:
        dicta[a] = b
    else:
        dicta[a] += b

dicts = sorted(dicta.items(), key = lambda x:x[0])
for i,v in dicts:
    num += v
    if num >= K:
        print(i)
        break

Submission status: Accepted

Solution code:
d = {}
n,k = map(int, input().split())
for _ in range(n):
    a,b = map(int, input().split())
    if d.setdefault(a):
        d[a] = d[a] + b
    else:
        d[a] = b
for key in sorted(d):
    k -= d[key]
    if k<=0:
        print(key)
        break

Submission status: Accepted

Solution code:
D = {}
N, K = map(int, input().split())
for i in range(N):
  A, B = map(int, input().split())
  if A in D:
    D[A] += B
  else:
    D[A] = B
C = sorted(D)
i, S = 0, 0
while S < K:
  S += D[C[i]]
  i += 1
print(C[i-1])

Submission status: Accepted

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

Submission status: Accepted

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

sm=0
for i in range(n):
      sm+=L[i][1]
      if sm>=k:
            print(L[i][0])
            exit()

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:(x[0],x[1]))
#print(AB)

for a,b in AB:
  if K <= b:
    print(a)
    exit()
  else:
    K -= b

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, K = MAP()
A = [MAP() for _ in range(N)]

A.sort()
cur = 0
for a in A:
	cur += a[1]
	if cur >= K:
		print(a[0])
		break

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
l = sorted(l, key=lambda x:x[0])
num = 0
for i in range(n):
  num += l[i][1]
  if num >= k:
    print(l[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.sort(key=lambda x: x[0])
sumB = 0
for a, b in AB:
    sumB += b
    if sumB >= K:
        print(a)
        break

Submission status: Accepted

Solution code:
import bisect
N, K = map(int, input().split())
a = []
b = []
for i in range(N):
    ta, tb = map(int, input().split())
    a.append(ta)
    b.append(tb)
dict = {}
for i in range(N):
    if a[i] in dict:
        dict[a[i]] += b[i]
    else:
        dict[a[i]] = b[i]
array = sorted(list(dict.items()))
ruiseki = [0]*len(array)
ruiseki[0] = array[0][1]
for i in range(1, len(array)):
    ruiseki[i] = ruiseki[i-1] + array[i][1]
print(array[bisect.bisect_left(ruiseki, K)][0])

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()
for i in range(N):
    if K <= lst[i][1]:
        print(lst[i][0])
        exit()
    else:
        K -= lst[i][1]

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n, k = map(int,input().split())
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key = lambda x: x[0])

for [i, j] in lst:
    if j >= k:
        print(i)
        quit()
    else:
        k -= j

Submission status: Accepted

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

lst = [[int(i) for i in input().split()] for _ in range(n)]

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

for [i, j] in lst:
    if j >= k:
        print(i)
        quit()
    else:
        k -= j

Submission status: Accepted

Solution code:
n , k = map(int, input().split())
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
data.sort()
total = 0
for i in data:
    if total < k <= total + i[1]:
        print(i[0])
        exit()
    else:
        total += i[1]

Submission status: Accepted

Solution code:
n,k=[int(i) for i in input().split()]
count=0
lst=[]
for i in range(n):
    lst.append([int(i) for i in input().split()])
lst.sort()
for i in range(n):
    a,b=lst[i]
    count+=b
    if(count>=k):
        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 = sorted(ab, key=lambda x:x[0])

c = 0
cur = 0
while True:
    if ab[cur][1] + c < k:
        c += ab[cur][1]
        cur += 1
    else:
        break
print(ab[cur][0])

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    AB=LLIN(N)
    AB.sort()
    for a,b in AB:
        K-=b
        if K<=0:
            print(a)
            exit()
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
lists=list(map(int,input().split()))
n=lists[0]
k=lists[1]
beforeSort = [[0]*2]*n
for i in range(n):
  getNum=list(map(int,input().split()))
  beforeSort[i]=getNum
afterSort=sorted(beforeSort)
for i in range(n):
  k=k-afterSort[i][1]
  if k<=0:
  	print(afterSort[i][0])
  	break

Submission status: Accepted

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


input_dict = {}

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

input_dict = sorted(input_dict.items(), key=lambda x:x[0])

for i in range(len(input_dict)):
    K -= input_dict[i][1]
    if K <= 0:
        print(input_dict[i][0])
        break

Submission status: Accepted

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

A.sort()
cnts=0
vals=0
for i in range(len(A)):
    cnts+=A[i][1]
    vals=A[i][0]
    if cnts>=K:
        print(vals)
        exit(0)

#print(A)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
li=sorted([list(map(int,input().split())) for _ in range(N)])
for l in li:
    K-=l[1]
    if K<=0:
        print(l[0])
        break

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
dic={}
for i in range(N):
  a,b=map(int,input().split())
  if a in dic:
    dic[a]+=b
  else:
    dic[a]=b
    
dic=sorted(dic.items(),key=lambda x:x[0])
for d in range(len(dic)):
  amount=dic[d][1]
  if amount>=K:
    print(dic[d][0])
    exit(0)
  else:
    K-=amount

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
a = []
b = []
s = [0 for i in range(10**5 + 1)]
for i in range(N):
  x,y = map(int,input().split())
  s[x] += y

for i in range(1,len(s)):
  if s[i]>=K:
    print(i)
    exit()
  K-=s[i]

Submission status: Accepted

Solution code:
import bisect
n, k = map(int, input().split())
M = sorted([ list(map(int, input().split())) for _ in range(n) ])
L = []
S = [0]
for a, b in M:
  L.append(a)
  S.append(S[-1]+b)
S = S[1:]
t = bisect.bisect_left(S, k)
print(L[t])

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import accumulate
import bisect

n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]

lin = [0]*(10**5)

for i in li:
    lin[i[0]-1] += i[1]

lis = list(accumulate(lin))

print(bisect.bisect_left(lis,k)+1)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
li=sorted([list(map(int,input().split())) for _ in range(N)])
for l in li:
  K-=l[1]
  if K<=0:
    print(l[0])
    exit()

Submission status: Accepted

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

L.sort()
cnt = 0
for i in range(N):
    cnt += L[i][1]
    if K <= cnt:
        ans = L[i][0]
        break
        
print(ans)

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    ab = [list(map(int, readline().split())) for _ in range(n)]
    ab.sort()
    t = 0
    for a, b in ab:
        t += b
        if t >= k:
            print(a)
            exit()


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

li = sorted(li,key = lambda x:x[0])
cnt = 0
for i in range(n):
  cnt += li[i][1]
  if k <= cnt:
    print(li[i][0])
    exit()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    AB=[tuple(map(int,input().split())) for _ in range(n)]
    AB.sort()
    for a,b in AB:
        k-=b
        if(k<=0):
            print(a)
            return
resolve()

Submission status: Accepted

Solution code:
# atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7

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

Cnt = [0]*(10**5+1)
for a,b in AB:
    Cnt[a] += b

i = 1
for ci in range(len(Cnt)):
    if i <= K < i+Cnt[ci]:
        print(ci)
        sys.exit()
    else:
        i += Cnt[ci]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split(" "))
l = []
a_l = []
for i in range(n):
  a, b = map(int, input().split(" "))
  l.append((a, b))
  
l = sorted(l)
for n in l:
  if k > n[1]:
    k = k - n[1]
    continue
  else:
    ans = n[0]
    break
    
print(ans)

Submission status: Accepted

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

counter = [0 for i in range(110000)]
for a,b in ablist:
    counter[a]+=b

for i in range(110000):
    K-=counter[i]
    if K<=0:
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
L = []
for i in range(N):
  a, b = [int(j) for j in input().split()]
  L.append([a, b])
L.sort(key=lambda x: x[0])
#print(L)

cnt = 0
for x, y in L:
  cnt += y
  if cnt >= K:
    ans = x
    break
print(ans)

Submission status: Accepted

Solution code:
import itertools
n, k = map(int, input().split())
l = [0] * 100010
for i in range(n):
    a, b = map(int, input().split())
    l[a] += b
d = 0
for i in range(1, 100001):
    d += l[i]
    if d >= k:
        print(i)
        break

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
X = sorted([[int(a) for a in input().split()] for _ in range(N)])
i = 0
K -= X[0][1]
while K > 0:
    i += 1
    K -= X[i][1]

print(X[i][0])

Submission status: Accepted

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

LIST=[[0,0] for i in range(N)]

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

LIST=sorted(LIST)

c=0
for i in range(N):
    c+=LIST[i][1]
    if(c>=K):
        print(LIST[i][0])
        exit()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
L=[0 for i in range(10**5+1)]
for i 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)
        exit()