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 = map(int, input().split())
l = [0] * (10**5 + 1)
for i in range(n):
    a, b = map(int, input().split())
    l[a] += b
s = 0
for i, v in enumerate(l):
    s += v
    if s >= k:
        print(i)
        break

Submission status: Accepted

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

ab.sort()

id = 0
for a, b in ab:
    if id + b >= K:
        print(a)
        break
    else:
        id += b

Submission status: Accepted

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

for i, x in enumerate(res):
    if k>x:
        k -= x
    else:
        print(i)
        exit()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
X=[]
for i in range (N):
	A=list(map(int,input().split()))
	X.append(A)
Y=sorted(X, key=lambda x:x[0])
tmp=0
for i in range (len(Y)):
	M=Y[i][1]
	tmp+=int(M)
	if tmp>=K:
		print(Y[i][0])
		exit()

Submission status: Accepted

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

n = 0
for i in range(N):
  if n + ab[i][1] < K:
    n += ab[i][1]
  else:
    print(ab[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(reverse=True)

while AB:
    a, b = AB.pop()
    K -= b
    if K <= 0:
        ans = a
        break

print(ans)

Submission status: Accepted

Solution code:
def main():
    N,K=map(int,input().split())
    ab=[0]*N
    for i in range(N):
        x=list(map(int,input().split()))
        ab[i]=x
    ab.sort(key=lambda x:x[0])

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

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    A = []
    B = []
    from bisect import bisect_left
    AB = [[int(i) for i in input().split()] for j in range(N)]
    AB.sort()
    A = [a[0] for a in AB]
    B = [a[1] for a in AB]
    from itertools import accumulate
    B = list(accumulate(B))
    idx = bisect_left(B, K)
    # print(A, B, idx)
    print(A[idx])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int,input().split())
ab = []
for i in range(n):
    ab.append([int(i) for i in input().split()])

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

Submission status: Accepted

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

from collections import defaultdict
from bisect import insort_left

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

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

ans = 0
for a,b in L_sorted:
    ans += b
    if ans >= K:
        print(a)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ab = []
for _ in range(n):
    a,b = map(int,input().split())
    ab.append([a, b])
ab.sort()
s = 0
for i in range(n):
    s += ab[i][1]
    if s >= k:
        print(ab[i][0])
        exit()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
arr = [0] * int(1e5+10)

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

for i in range(100001):
        k -= arr[i]
        if k<=0:
                print(i+1)
                break

Submission status: Accepted

Solution code:
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import collections
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, k = list(map(int,ipti().split()))
    nn = [0] * (10**5 + 1)

    for i in range(n):
        a, b = list(map(int,ipti().split()))
        nn[a] += b

    cnt = 0
    for i in range(10**5 + 2):
        cnt += nn[i]
        if cnt >= k:
            print(i)
            sys.exit()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    nums = [tuple(map(int, input().split())) for _ in range(n)]
    nums.sort(key = lambda x:x[0])

    for num in nums:
        if num[1] >= k:
            print(num[0])
            break
        else:
            k -= num[1]

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

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


dd = defaultdict(int)

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

cnt = 0
for key, v in sorted(dd.items()):
    cnt += v
    if k <= cnt:
        print(key)
        break

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split()]
cnt = [0] * int(10e5)
for i in range(n):
    a, b = [int(i) for i in input().split()]
    cnt[a] += b

for i in range(1, len(cnt)):
    if k <= cnt[i]:
        print(i)
        break
    k -= cnt[i]

Submission status: Accepted

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

count = [0 for i in range(200000)]
for i in range(n):
    a,b = map(int, input().split())
    count[a-1] += b 

cnt = 0 
for i in range(100001):
    if cnt < k  and cnt + count[i] >=k :
        print(i+1)
        break
    cnt +=count[i]

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(1, 10**5+1):
    sum_d += d[i]
    if(sum_d >= K):
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(N)]
ab.sort(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())
num=[list(map(int,input().split())) for i in range(n)]
num.sort(key=lambda s:s[0])
for i in range(n):
    a,b=num[i][0],num[i][1]
    if k-b>0:
        k-=b
    else:
        print(a)
        break

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])
i = 0

while K-AB[i][1]>0:
    K -= AB[i][1]
    i += 1

print(AB[i][0])

Submission status: Accepted

Solution code:
def main():
    operation, target = map(int, input().split())
    count = [0] * (10 ** 5 + 1)
    for _ in range(operation):
        a, b = map(int, input().split())
        count[a] += b
    for i in range(1, 10 ** 5 + 2):
        if target <= count[i]:
            print(i)
            break
        else:
            target -= count[i]


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)

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

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

d_sorted = sorted(d.items())
cnt = 0
for k,v in d_sorted:
  cnt += v
  if cnt >= K:
    ans = k
    break

print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
clis = [0]*10**5

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

Submission status: Accepted

Solution code:
# ABC061c
from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
nums = [list(map(int, input().split())) for _ in range(n)]
nums.sort()
i = 0
for a, b in nums:
    i += b
    if i >= k:
        print(a)
        exit(0)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append([a, b])
ab.sort()
cnt = 0
for i, v in ab:
    cnt += v
    if cnt < k:
        pass
    else:
        print(i)
        break

Submission status: Accepted

Solution code:
def solve():
    N, K = [int(_) for _ in input().split()]
    AB = [[int(_) for _ in input().split()] for i in range(N)]
    AB.sort()
    k = 0
    for a, b in AB:
        k += b
        if K <= k:
            return a

if __name__ == '__main__':
    print(solve())

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
cnt=[0]*100001
for i in range(N):
    a,b=map(int,input().split())
    cnt[a]+=b
ans=0
tmp=0
for i in range(100001):
    tmp+=cnt[i]
    if(tmp>=K):
        ans=i
        break
print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

b = [] #amount
a = [] #index

lst1 = [list(map(int,readline().split())) for i in range(n)]
lst1.sort()
for i,j in lst1:
    b.append(j)
    a.append(i)

for i in range(1,n):
    b[i] += b[i-1]

for i in range(n):
    if b[i] >= k:
        print(a[i])
        exit()

Submission status: Accepted

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

count= []
ans = 0
for i in range(n):
    ab = list(map(int,input().split()))
    count.append(ab)
count.sort()
i = 0
while ans < k:
    ans +=count[i][1]
    i +=1
print(count[i-1][0])

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.sort()
#print(a)
count=0
i=0
while count<k:
    count+=a[i][1]
    i+=1

print(a[i-1][0])

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int, input().split())
A = np.array([0] * (10**5 + 1))
for _ in range(N):
    a, b = map(int, input().split())
    A[a] += b
cumsum = A.cumsum()
ans = (cumsum >= K).nonzero()[0].min()
print(ans)

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
d = list(d.items())
d = sorted(d, key=lambda x: x[0])
cnt = 0
for v, count in d:
    cnt += count
    if cnt >= K:
        print(v)
        exit()

Submission status: Accepted

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

n = 0
for x in sorted(dic.keys()):
    n += dic[x]
    if K <= n:
        print(x)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    N, K = Scanner.map_int()
    S = defaultdict(int)
    for i in range(N):
        a, b = Scanner.map_int()
        S[a] += b
    n = 0
    for i in range(100001):
        n += S[i]
        if n >= K:
            print(i)
            return
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[]
for i in range(n):
    a_i,b_i=map(int,input().split())
    a.append([a_i,b_i])
a.sort()
num=0
for i in range(n):
    num+=a[i][1]
    if num>=k:
        print(a[i][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.sort()
count = 0
for i,j in l:
  if j < k:
    k -= j
  else:
    print(i)
    exit()

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)

N, K = map(int, input().split())
li = [list(map(int, input().split())) for n in range(N)]

for i in li:
  d[i[0]] += i[1]
  
count = 0
new = sorted(d)

for i in new:
  count += d[i]
  
  if count >= K:
    print(i)
    break

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N,K=list(map(int,input().split()))
    AB=[tuple(map(int,input().split())) for i in range(N)]
    AB.sort(key=lambda x:x[0])
    for a,b in AB:
        K-=b
        if K<=0:
            print(a)
            break

Submission status: Accepted

Solution code:
# coding: utf-8
N,K=map(int,input().split())
cnt=0
L=[]

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
amax = 100000
cnt = [0 for _ in range(amax+1)]


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

for i in range(1, amax+1):
    if k <= cnt[i]:
        print(i)
        break
    k -= cnt[i]

Submission status: Accepted

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

ab.sort()

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

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])

ab = sorted(ab)

count = 0

for a, b in ab:
    count += b
    if k <= count:
        print(a)
        exit()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
numberdict = {}
for j in range(N):
    a, b = map(int, input().split())
    if a in numberdict:
        numberdict[a] += b
    else:
        numberdict[a] = b
numberdict = sorted(numberdict.items())
# print(numberdict)
index = 0
for i in range(len(numberdict)):
    index += numberdict[i][1]
    if index >= K:
        print(numberdict[i][0])
        break

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
dic = {str(i):0 for i in range(10**5 + 5)}
for _ in range(N):
    a,b = map(int,input().split())
    dic[str(a)] += b
z = 0
for i in range(10**5 + 5):
    z += dic[str(i)]
    if z >= K:
        ans = i
        break
print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a=[]
for i in range(N):
    c,d=map(int,input().split())
    a.append((c,d))
#xについてソート
a.sort()
count = 0
for x,y in a:
    count += y
    if count>=K:
        print(x)
        exit()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a=[]
for i in range(N):
    c,d=map(int,input().split())
    a.append((c,d))
a.sort()
count = 0
for x,y in a:
    if y>=K:
        print(x)
        exit()
    else:
        K -= y

Submission status: Accepted

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

Submission status: Accepted

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

ab = []
for i in range(n):
  ta,tb = map(int,input().split())
  ab.append([ta,tb])

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

count = k
for i in range(n):
  count -= ab[i][1]
  if count <= 0:
    print(ab[i][0])
    break

Submission status: Accepted

Solution code:
from collections import defaultdict
N, K = map(int, input().split())
dic = defaultdict(int)
for i in range(N):
    a, b = map(int, input().split())
    dic[a] += b
count = 0
for k, v in sorted(dic.items()):
    count += v
    if count >= K:
        print(k)
        break

Submission status: Accepted

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

d = {}
for i in range(N):
    if A[i] in d:
        d[A[i]] = d[A[i]] + B[i]
    else:
        d[A[i]] = B[i]

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

for a, b in list:
    if M - b <= 0:
        print(a)
        break
    M -= b

Submission status: Accepted

Solution code:
def smallk(n , k , ab):
    count = 0
    for i in range(n):
        if count + int(ab[i][1]) >= k:
            return int(ab[i][0])
        else:
            count += int(ab[i][1])

def main():
    n , k = map(int , input().split())
    ab = [list(map(int,input().split())) for i in range(n)]
    ab.sort()
    print(smallk(n , k , ab))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N,K = [int(i) for i in input().split()]
ab = [0] * N
for i in range(N) :
    ab[i] = [int(i) for i in input().split()]
ab.sort()
sum = 0
for i in range(N) :
    sum += ab[i][1]
    if sum >= K:
        print(ab[i][0])
        break

Submission status: Accepted

Solution code:
import heapq

def solve():
    N,K = map(int, input().split())
    nums = []
    num_dict = {}
    for _ in range(N):
        a,b = map(int, input().split())
        if a not in num_dict:
            heapq.heappush(nums, a)
            num_dict[a] = b
        else:
            num_dict[a] += b
            
    ret = 0
    while K>0:
        ret = heapq.heappop(nums)
        
        K -= num_dict[ret]
        
    print(ret)
    
solve()

Submission status: Accepted

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

count = 0
for a, b in sorted(AB):
    count += b
    if count >= K:
        print(a)
        break

Submission status: Accepted

Solution code:
def solve(n, k, AB):
    AB.sort(key=lambda ab: ab[0])
    count = 0
    ret = -1
    for a, b in AB:
        count += b
        if k <= count:
            ret = a
            break
    return ret

_n, _k = map(int, input().split())
_AB = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _k, _AB))

Submission status: Accepted

Solution code:
from operator import itemgetter
import sys

def read():
    return sys.stdin.readline().rstrip()

n, k = map(int, input().split())
ab = sorted([[int(i) for i in read().split()] for _ in range(n)], key=itemgetter(0))
c = 0
for a, b in ab:
    c += b
    if c >= k:
        print(a)
        break

Submission status: Accepted

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

A_list = [[0, j] for j in range(N)]
B_list = [0] * N

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

A_list.sort()
sort_key = [j[1] for j in A_list]
B_list_sort = [B_list[j] for j in sort_key]

for i in range(10 ** 5):
    K -= B_list_sort[i]
    if K <= 0:
        print(A_list[i][0])
        break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ab = []
for i in range(n):
    ai, bi = map(int, input().split())
    ab.append((ai, bi))
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:
n, k = map(int, input().split())
lis = []
for i in range(n):
    a = list(map(int, input().split()))
    lis.append(a)
lis.sort()
cnt = 0
for i in range(n):
    cnt += lis[i][1]
    if cnt >= k:
        print(lis[i][0])
        break

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(N)]
sorted_lst = sorted(lst, key=lambda x: x[0])
cnt = 0
for i in sorted_lst:
  cnt += i[1]
  if (cnt >= K):
    print(i[0])
    break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
L = [0]*(pow(10,5)+1)

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

s = 0
for i in range(pow(10,5)+1):
  s += L[i]
  if s >= k:
    print(i)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
x = []
for i in range(n):
	a,b = map(int, input().split())
	x.append([a,b])
x.sort()
c = 0
for i,j in x:
	c += j
	if k <= c:
		print (i)
		exit()
print (j)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
A.sort()
k=K
i=0
while k>0:
  k-=A[i][1]
  ans=A[i][0]
  i+=1
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n,m = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
	a[i],b[i] = map(int,input().split())
a,b = zip(*sorted(zip(a,b)))
cur_sum = 0
for i in range(n):
	cur_sum += b[i]
	if cur_sum >= m:
		print(a[i])
		exit(0)

Submission status: Accepted

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

D = sorted(list(D.items()))
k = 0
for a, b in D:
  k += b
  if k>=K:
    print(a)
    exit()

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
	sys.stdin=open('input_file.txt')
	
#+++++
n,k=list(map(int, input().split()))
aa={}
for _ in range(n):
	a,b = list(map(int, input().split()))
	t = aa.get(a,0)
	aa[a] = t+b

sa = sorted(aa.keys())
for a in sa:
	if k > aa[a]:
		k -= aa[a]
	else:
		print(a)
		break

Submission status: Accepted

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

ls.sort()

ln = 0

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

Submission status: Accepted

Solution code:
from heapq import heappop, heappush
N, K = map(int, input().split())
AB = []

cnt = 0
for i in range(N):
  a, b = map(int, input().split())
  heappush(AB, (a, b))


while AB:
  a, b = heappop(AB)
  cnt += b
  
  if K <= cnt:
    print(a)
    exit()

Submission status: Accepted

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

sA = []
for i in range(n):
  sA.append(list(map(int,input().split())))

sA.sort()

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
l = [0] * (10 ** 5 + 1)
for i in ab:
    l[i[0]] += i[1]
s = 0
for i in range(10 ** 5 + 1):
    s += l[i]
    if s >= k:
        print(i)
        break

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	#入力
	N, K  = map(int,input().split())
	lst = []
	for i in range(0,N):
		a, b = map(int,input().split())
		lst.append([a,b])

	lst.sort()
	indx = 0

	for i in range(0,N):
		indx += lst[i][1]
		if indx >= K:
			ans = lst[i][0]
			break

	print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
AB = sorted(tuple(map(int, input().split())) for _ in range(N))
for a, b in AB:
    if K <= b:
        print(a)
        break
    else:
        K -= b

Submission status: Accepted

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

res = [0]*10**5

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

count = 0
for i,r in enumerate(res):
    count+=r
    if count >= M:
        print(i+1)
        break

Submission status: Accepted

Solution code:
import sys
import numpy as np

# N K 操作回数、K番目の値
n, k = map(int, input().split())

# ai, bi  追加する整数 ai, 追加する数 bi
s = []
for i in range(n):
    s.append(list(map(int, input().split())))

# ai, bi の順にソート
s.sort()

number = 0
for s_item in s:
    # kの位置以上に来たか
    number += s_item[1]
    if number >= k:
        number_k = s_item[0]
        break

print(number_k)

Submission status: Accepted

Solution code:
from collections import defaultdict
N, K = map(int, input().strip().split())
ab = [list(map(int, input().strip().split())) for _ in range(N)]

dic = defaultdict(int)
for a, b in ab:
  dic[a] += b

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    ab = []
    for _ in range(N):
        ab.append([int(x) for x in input().split()])

    count = 0
    i = -1
    ab.sort()
    while count < K:
        i += 1
        count += ab[i][1]

    print(ab[i][0])






if __name__ == '__main__':
    main()

Submission status: Accepted

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

for n in sorted(ab, key=lambda x: x[0]):
    cnt += n[1]
    if cnt >= K:
        ans = n[0]
        break

print(ans)

Submission status: Accepted

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

List.sort()
cnt = 0

for i in range(len(List)):
  cnt = cnt + List[i][1]
  if cnt >= K:
    ans = List[i][0]
    break
print(ans)

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])
tmp=0
for a,b in ab:
  tmp+=b
  if tmp>=k:
    print(a) 
    exit()

Submission status: Accepted

Solution code:
def main():
    MAX = 100010
    n,k = map(int,input().split())
    m = {}
    for x in range(100010):
        m[x] = 0
    for x in range(n):
        a,b = map(int,input().split())
        m[a] += b
    if k == 0:
        print(m.keys()[0])
        return
    for key,value in m.items():
        k-=value
        if k <= 0:
            print(key)
            return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ab.sort()

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

Submission status: Accepted

Solution code:
from collections import defaultdict as DD
N, K = map(int,input().split())
D = DD(int)
for i in range(N):
  a, b = map(int,input().split())
  D[a] += b

L = sorted(D.items(), key = lambda x: x[0])
i = 0
while True:
  if L[i][1] >= K:
    print (L[i][0])
    break
  else:
    K -= L[i][1]
    i += 1

Submission status: Accepted

Solution code:
n,k=[int(i) for i in input().split()]
array=[]
for i in range(n):
    a,b=[int(_) for _ in input().split()]
    array.append(tuple([a,b]))
array.sort(key=lambda x:x[0])
count=0
for a,b in array:
    count+=b
    if count>=k:
        print(a)
        break