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:
import numpy as np

n, k = map(int, input().split())
z = np.zeros(10**5 + 1, dtype = np.int64)
for i in range(n):
  a, b = map(int, input().split())
  z[a] += b

a = 0
for i in range(1, 10**5 + 1):
  if k <= z[i]:
    a = i
    break
  k -= z[i]

print(a)

Submission status: Accepted

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

a = 0
for i in range(1, 10**5+1):
  if i in d and k <= d[i]:
    a = i
    break
  k -= d[i] if i in d else 0

print(a)

Submission status: Accepted

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

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

AB.sort()
for ab in AB:
    K -= ab[1]
    if K <= 0:
        print(ab[0])
        exit()

Submission status: Accepted

Solution code:
def solve():
    n, k = list(map(int, input().split(" ")))
    A, B = [], []
    for _ in range(n):
        tmp_a, tmp_b = list(map(int, input().split(" ")))
        A.append(tmp_a)
        B.append(tmp_b)

    num = [0 for _ in range(10 ** 5 + 1)]
    for a, b in zip(A, B):
        num[a] += b

    summation = 0
    for i, ele in enumerate(num):
        summation += ele
        if summation >= k:
            print(i)
            break


solve()

Submission status: Accepted

Solution code:
inp = input().split(" ")
N = int(inp[0])
K = int(inp[1])

keys = list(range(1, 100001))
arr = {i:0 for i in keys}

for i in range(N):
	inp = input().split(" ")
	a = int(inp[0])
	b = int(inp[1])
	arr[a] += b

for i in keys:
	K -= arr[i]
	if K <= 0:
		print(i)
		break

Submission status: Accepted

Solution code:
nk = input().split(' ')
n = int(nk[0])
k = int(nk[1])

arr = []

for i in range(0, n):
	ab = input().split(' ')
	arr.append((int(ab[0]), int(ab[1])))

arr = sorted(arr)

pos = 0
while True:
	if k > arr[pos][1]:
		k -= arr[pos][1]
	else:
		print(arr[pos][0])
		break
	pos += 1

Submission status: Accepted

Solution code:
line_one = raw_input().split()
n = int(line_one[0])
k = int(line_one[1])

tuples = []
arr = []
for i in range(n):
    line = raw_input().split()
    tuples.append( (int(line[0]), int(line[1]))  )

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

total = 0
for tup in tuples:
    total += tup[1]
    if total >= k:
        print tup[0]
        break

Submission status: Accepted

Solution code:
x = raw_input().split(" ")
num_operations = int(x[0])
kth_integer = int(x[1])
field = {}
for p in range(0, num_operations):
 line = raw_input().split(" ")
 a = int(line[0])
 b = int(line[1])
 if a in field:
  field[a] += b
 else:
  field[a] = b
ks = field.keys()
ks.sort()
out = field.keys()[-1]
for k in ks:
 kth_integer -= field[k]
 if (kth_integer <= 0):
  out = k
  break
print (out)

Submission status: Accepted

Solution code:
def main():
    n, k = [int(x) for x in input().split(' ')]
    arr = [0] * 100001
    for _ in range(n):
        a, b = [int(x) for x in input().split(' ')]
        arr[a] += b
    foo = 0
    for i, e in enumerate(arr):
        foo += e
        if (foo >= k):
            print(i)
            break

main()

Submission status: Accepted

Solution code:
import heapq
N,K=map(int,raw_input().split())
c=[]
for i in range(N):
	heapq.heappush(c, tuple( map(int,raw_input().split()) ) )

cnt=0
for i in range(len(c)):
	val=heapq.heappop(c)
	cnt+=val[1]
	if K<=cnt:
		print val[0]
		break

Submission status: Accepted

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

for i in range(1, 10 ** 5 + 2):
    if K <= nums[i]:
        print(i)
        break
    K -= nums[i]

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://abc061.contest.atcoder.jp/tasks/abc061_c

"""
import sys
from sys import stdin
from itertools import accumulate
from bisect import bisect_left
input = stdin.readline


def main(args):
    N, K = map(int, input().split())

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

    acc = list(accumulate(freq))
    i = bisect_left(acc, K)
    print(i)


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, raw_input().split())    
ab = [map(int, raw_input().split()) for i in xrange(N)]
ab.sort()
for a, b in ab:
    if K <= b:
        print a
        break
    else:
        K -= b

Submission status: Accepted

Solution code:
from sys import stdin, stdout
from collections import defaultdict
def readLine_int_list():return list(map(int, stdin.readline().split()))
def main():
    n,k = readLine_int_list()
    
    l = defaultdict(lambda: 0)
    for i in range(n):
        a,b =readLine_int_list()
        l[a] += b
    
    cnt = 0
    for key in sorted(l.keys()):
        val = l[key]
        cnt += val
        if cnt >= k:
            print(key)
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N , K = map(int,input().split())
cnt =0
get_val = [[0,0]]*N
for i in range(N):
    get_val[i] = list(map(int,input().split()))
get_val.sort()

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

Submission status: Accepted

Solution code:
cnt_a = [0] * 100001

N, K = [int(n) for n in input().split()]
for n in range(N):
  a, b = [int(i) for i in input().split()]
  cnt_a[a] += b

cnt = 0
for n in range(100001):
  cnt += cnt_a[n]
  if cnt >= K:
    print(n)
    import sys
    sys.exit(0)

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
import sys
input = sys.stdin.readline

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

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

d = sorted(d.items())
for i,j in d:
    K -= j
    if K <= 0:
        print(i)
        break

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]=d[a]+b
    else:
        d.setdefault(a,b)

d = sorted(list(d.items()))

for i in range(len(d)):
    K = K - d[i][1]
    if K <= 0:
        print(d[i][0])
        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()

for a, b in ab:
    K -= b
    if K <= 0:
        print(a)
        break

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
ans = []
A = [[]*2]*N
num = 0
for i in range(N):
    A[i] = [int(i) for i in input().split()]
A.sort()
i = 0
while num < K:
    num += A[i][1]
    i += 1

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

Submission status: Accepted

Solution code:
col = {}
N, K = [int(i) for i in input().split()]
for _ in range(N):
	a_i, b_i = [int(i) for i in input().split()]
	if not a_i in col:
		col[a_i] = b_i
	else:
		col[a_i] += b_i

count = 0
for i in sorted(col.items()):
	count += i[1]
	if count >= K:
		print(i[0])
		break

Submission status: Accepted

Solution code:
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


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


l.sort()
i = 0
cnt = 0
ans = -1
while True:
    a, b = l[i]
    K -= b
    if K <= 0:
        ans = a
        break

    i += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
d = [0] * 10**5
N, K = [int(x) for x in sys.stdin.readline().split()]

for i in range(N):
    a, b = [int(x) for x in sys.stdin.readline().split()]
    d[a-1] += b
    
cnt = 0

for i, j in enumerate(d):
    cnt += j
    if cnt >= K:
        print(i+1)
        break

Submission status: Accepted

Solution code:
import sys
import bisect

N, K = map(int, sys.stdin.readline().split())
d = []


for i in range(N):
    a, b = map(int, sys.stdin.readline().split())
    d.append([a,b])

d.sort()

l = [0] * N
l[0] = d[0][1]

for i in range(1, N):
    l[i] = d[i][1]+ l[i-1]

pos = bisect.bisect_left(l, K)
print(d[pos][0])

Submission status: Accepted

Solution code:
import bisect

N, K = map(int, input().split())
d = []


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

d.sort()

l = [0] * N
l[0] = d[0][1]

for i in range(1, N):
    l[i] = d[i][1]+ l[i-1]

pos = bisect.bisect_left(l, K)
print(d[pos][0])

Submission status: Accepted

Solution code:
n,k=[int(x) for x in input().split()]
s=[]
for i in [None]*n:
    a,b=[int(x) for x in input().split()]
    s.append((a,b))
s=sorted(s,key=lambda x : x[0])
for i in s:
    if i[1]>=k:
        print(i[0])
        break
    else:
        k-=i[1]

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    n, k = map(int, input().split())

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

l = []

for i in range(N):
    a, b = map(int, input().split())
    l.append((a,b))
def c(x):
    return  x[0]
l = sorted(l, key=c)
t = 0
for a,b in l:
    t2 = t
    t += b
    if t2 <= K and t >= K:
        break

print(a)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
dic = {}
lst = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    if (a in dic)==False:
        dic[a] = b
        lst.append(a)
    else:
        dic[a] += b
lst.sort()

for i in range(len(dic)):
    if k > (dic[lst[i]] + ans):
        ans += dic[lst[i]]
    else:
        ans = lst[i]
        break
print(ans)

Submission status: Accepted

Solution code:
m = {}
n, k = map(int, input().split())
for j in range(0, n):
    a, b = map(int, input().split())
    m[a] = (m[a] if a in m else 0) + b

i = 0
for a, b in sorted(m.items()):
    i += b
    if i >= k:
        print(a)
        break

Submission status: Accepted

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

Submission status: Accepted

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

d = dict()

for i in range(N):
    a, b = list(map(int, input().split(" ")))
    if a in d:
        d[a] = d[a] + b
    else:
        d[a] = b
    
ans_sum = 0

for key in sorted(d.keys()):
    ans_sum += d[key]
    if (ans_sum) >= K:
        print(key)
        break

Submission status: Accepted

Solution code:
N,K=list(map(int,input().split()))
l=[]
for i in range(N):
 a,b=list(map(int,input().split()))
 l.append((a,b))  
l.sort()
s = 0
for a,b in l:
    s += b
    if K <= s:
        print(a)
        break

Submission status: Accepted

Solution code:
def main():
    N, K = list(map(int, input().strip().split()))
    num_counts = {}
    for _ in range(N):
        a, b = list(map(int, input().strip().split()))
        if a in num_counts:
            num_counts[a] += b
        else:
            num_counts[a] = b

    num_counts = sorted(num_counts.items(),
                        key=lambda x: x[0])
    for n, c in num_counts:
        if K - c <= 0:
            print(n)
            break
        K -= c

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict


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

    total = 0
    for k, v in sorted(d.items()):
        if total < K <= total + v:
            print(k)
            return
        total += v


if __name__ == '__main__':
    main()

Submission status: Accepted

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

nums.sort(key=lambda x:x[0])
#print(nums)
sum = 0
for i in range(0, n):
    sum +=nums[i][1]
    if sum >= k:
        print(nums[i][0])
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Big Array
n,k =  list(map(int, input().split()))

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

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

Submission status: Accepted

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

nums = {}

for _ in range(N):
    a, b = list(map(int, input().split(" ")))
    
    if a in nums:
        nums[a] += b
    else :
        nums[a] = b
        
acc = 0
for key in sorted(nums.keys()):
    acc += nums[key]
    if acc >= K:
        print(key)
        break

Submission status: Accepted

Solution code:
import sys

N, K = (int(i) for i in raw_input().split())
ab_list = [[int(i) for i in raw_input().split()] for i in range(N)]
ab_list = sorted(ab_list, key=lambda ab: ab[0])

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np

n, k = map(int, input().split())
memo = np.zeros(100010, dtype=np.int)

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

s = 0
for i in range(len(memo)):
    s += memo[i]
    if k <= s:
        print(i)
        exit()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
arr=[]
for _ in range(n):
    arr.append(tuple(map(int,input().split())))
arr.sort(key=lambda x:x[0])
cur=0
for pair in arr:
    cur+=pair[1]
    if cur>=k:
        print(pair[0])
        break

Submission status: Accepted

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

for i in range(N):
    x,y = (map(int, input().split()))
    l.append((x,y))
l.sort()
cnt = 0
ans = 0
index = 0
while cnt < K:
    ans = l[index][0]
    cnt += l[index][1]
    index += 1

print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
list1 = []
for i in range(N):
    list1.append(list(map(int,input().split())))
num = [0]*(10**5+1)
for j in range(N):
    num[list1[j][0]] += list1[j][1]
c = 0
d = 0
for k in range(10**5+1):
    c += num[k]
    if c >= K:
        d = k
        break
print(d)

Submission status: Accepted

Solution code:
A = [0 for _ in xrange(10**5+10)]
N, K = map(int, raw_input().split())
for i in xrange(N):
    a, b = map(int, raw_input().split())
    A[a] += b
     
k = 0
for i in xrange(10**5+10):
    k += A[i]
    if k >= K:
        print i
        break

Submission status: Accepted

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

def get_ans():
    n, k = map(int, raw_input().split())
    src = []
    for i in range(n):
        src.append(map(int, raw_input().split()))
    src.sort(key=lambda x:x[0]) # 0番目の要素でソート

    cnt = 0
    for a, b in src:
        cnt = cnt + b
        if cnt >= k:
            return a
            break
    return src[n-1][1]

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

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('c1.in')

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

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

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

Submission status: Accepted

Solution code:
N,K = [int(i) for i in input().split(" ")]
num = [0]*((10**5)+1)
for i in range(N):
    a_k,b_k = [int(i) for i in input().split(" ")]
    num[a_k] += b_k
for i, v in enumerate(num): # i は index v は 中身
    K = K - v
    if K<=0:
        print(i)
        break

Submission status: Accepted

Solution code:
N,K=map(int,raw_input().split())
K-=1
s={}
for i in range(N):
    a,b=map(int,raw_input().split())
    if a in s:
        s[a] += b
    else:
        s[a] = b

c=sorted(s.items())

index = 0
for i in c:
    index += i[1]
    if K<index:
        print i[0]
        break

Submission status: Accepted

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

# initialize
N,K = map(int, input().split())
list = [0] * (10**5+1)

# In:list, Out:ans
def solve(k,l):
    for i in range(len(l)):
        k -= l[i]
        if (k <= 0):
            return i
    return 0

# Input a and b to the list
for i in range(N):
    a,b = map(int, input().split())
    list[a] += b

print(str(solve(K,list)))

Submission status: Accepted

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

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

for m in m_list:
    count += m[1]
    if count >= K:
        print(m[0])
        break

Submission status: Accepted

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

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

A = []
table = []

for i in range(N):
    #二つの整数を読み取って、配列としてたす
    a,b = map(int,input().split())
    table.append([a,b])

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import heapq

def solve():
  firstline = raw_input().split(' ')
  N = int(firstline[0])
  K = int(firstline[1])

  heap = []
  for i in range(N) :
    ar = raw_input().split(' ')
    a = int(ar[0])
    b = int(ar[1])
    heapq.heappush(heap, (a, b))

  count = 0
  while len(heap) > 0 :
    t = heapq.heappop(heap)
    count += t[1]
    if (count >= K) : return t[0]
  return -1

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

Submission status: Accepted

Solution code:
from sys import stdin
n,k = map(int,stdin.readline().split())
a = []
for _ in xrange(n):
    x,y = map(int,stdin.readline().split())
    a.append( (x,y) )
a.sort()
cur = 0
for x,y in a:
    cur += y
    if cur >=k:
        break
print x

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split()))
data = []
def insert(num,N,K):
    for i in range(N):
        if num[i][1] >= K:
            print(num[i][0])
            break
        else:
            K -= num[i][1]
num = [list(map(int,input().split())) for i in range(N)]
num.sort(key=lambda x:x[0])
insert(num,N,K)

Submission status: Accepted

Solution code:
import sys

def solve():
    N, K = map(int, sys.stdin.readline().split())
    p = [tuple(map(int, sys.stdin.readline().split())) for i in range(N)]

    p.sort()

    cnt = 0

    for ai, bi in p:
        cnt += bi

        if cnt >= K:
            print(ai)
            return

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

p.sort()

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

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( key = lambda x: x[0] )
pos = 0
for val in data:
    pos += val[1]
    if k <= pos:
        print(val[0])
        break

Submission status: Accepted

Solution code:
# coding: utf-8

l = 10 ** 5
num = [0] * (l + 1)
n, k = map(int, raw_input().split())

for _ in xrange(n):
    a, b = map(int, raw_input().split())
    num[a] += b

for i in xrange(1, l+1):
    k -= num[i]
    if k <= 0:
        print i
        break

Submission status: Accepted

Solution code:
tmp = input().split(" ")
K = int(tmp[1])
 
num = [0 for i in range(10**5)]
for i in range(int(tmp[0])):
    tmp = input().split(" ")
    num[int(tmp[0])-1] += int(tmp[1])
    
tmp = 0
i = 0
while tmp < K:
    tmp = tmp + num[i]
    if tmp >= K:
        print(i+1)
    i = i + 1

Submission status: Accepted

Solution code:
tmp1 = list(map(int, input().split(" ")))
num = [0 for i in range(10**5)]
for i in range(tmp1[0]):
    tmp = list(map(int, input().split(" ")))
    num[tmp[0]-1] += tmp[1]
tmp = 0
i = 0
while tmp < tmp1[1]:
    tmp = tmp + num[i]
    if tmp >= tmp1[1]:
        print(i+1)
    i = i + 1

Submission status: Accepted

Solution code:
# N,Kの把握
l1 = list(map(int, input().split()))
N = l1[0]
K = l1[1]

#リストをすぐに作成するのが悪手。数値と回数をセット作成
dic = {}
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	if a in dic:
		dic[a] += b #既に存在する数値であればそのまま回数を＋
	else:
		dic.update({a: b}) #新規の数値であれば追加

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

x = 0
for key, value in dic: #回数値を足していき、総回数＞＝Kとなったときの数値を出力する。
	x += value
	if x >= K:
		print(str(key))
		break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    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])
    count = 0
    for i in ab:
        count += i[1]
        if K <= count:
            print(i[0])
            break

Submission status: Accepted

Solution code:
tmp = input().split(" ")
N = int(tmp[0])
K = int(tmp[1])

num = [0 for i in range(10**5)]
for i in range(N):
    tmp = input().split(" ")
    a = int(tmp[0])
    b = int(tmp[1])
    num[a-1] = num[a-1] + b

tmp = 0
i = 0
while tmp < K:
    tmp = tmp + num[i]
    if tmp >= K:
        print(i+1)
    i = i + 1

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
alllist=[]
goukei=1
for i in range(a):
    tmplist=list(map(int,input().split()))
    alllist.append(tmplist)

alllist2=sorted(alllist)
for i in range(a):
    goukei=alllist2[i][1]+goukei
    if goukei>b:
        owari=alllist2[i][0]
        break
    else:
        pass

print(owari)

Submission status: Accepted

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

array = []
count = 0
for i in range(N):
    array.append(tuple(map(int, input().split())))

array.sort()
K -= 1
for tup in array:
    if K < tup[1]:
        print(tup[0])
        break
    else:
        K -= tup[1]

Submission status: Accepted

Solution code:
from collections import defaultdict
n,k = map(int, raw_input().split())
d = defaultdict(int)
for _ in range(n):
    a,b = map(int, raw_input().split())
    d[a] += b
s = 0
for p in sorted(d.keys()):
    if k <= s + d[p]:
        print p
        break
    s += d[p]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = []
for i in range(n):
    x,y = map(int, input().split())
    a.append((x,y))
a.sort()
for x,y in a:
    if y >= k:
        print(x)
        exit()
    else:
        k -= y

Submission status: Accepted

Solution code:
# ==================================================== #
# -*- coding: utf-8 -*
n, k = map(int, input().split())

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

for i in range(n):
    k -= arr[i][1]
    if k <= 0:
        print(arr[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)]
ab.sort()

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())
a = []
d = {}
for i in range(N):
    ls = list(map(int, input().split()))
    if ls[0] in d:
        d[ls[0]] = d[ls[0]] + ls[1]
    else:
        d[ls[0]] = ls[1]
d = sorted(d.items())
cnt = 0
for t in d:
    cnt += t[1]
    if cnt >= K:
        print(t[0])
        break

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

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

cnt = 0
for x in sorted(di.keys()):
    cnt += di[x]
    if cnt >= k:
        print(x)
        sys.exit()

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N,K = map(int, input().split())
    deg = [0 for x in range(10 ** 5 + 1)]
    for x in range(N):
        a,b = map(int, input().split())
        deg[a] += b
    res = 0
    for i,val in enumerate(deg):
        res += val
        if (res >= K):
            print (i)
            break

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
V = {}
for i in range(N):
    a, b = map(int, raw_input().split())
    if not a in V:
        V[a] = 0
    V[a] += b
for v, num in sorted(V.items()):
    K -= num
    if K <= 0:
        print v
        break

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
counter = {}
for i in range(n):
    a, b = map(int, raw_input().split())
    if counter.has_key(a):
        counter[a] += b
    else:
        counter[a] = b

num = 0
for ele in sorted(counter.items()):
    num += ele[1]
    if k <= num:
        print ele[0]
        break

Submission status: Accepted

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

L = []
for i in range(100000):
	L.append(0)

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

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

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=sorted(tuple(d.items()),key=lambda a:a[0])
for i in d:
	if cnt+i[1]>=k:
		print(i[0]);quit()
	cnt+=i[1]

Submission status: Accepted

Solution code:
#ABC061C

n,k=map(int,raw_input().split())
l=[]
for i in xrange(n):
 a,b=map(int,raw_input().split())
 l.append((a,b))
l.sort()
s=0
for i in xrange(n):
 s+=l[i][1]
 if s>=k:
  print l[i][0]
  break

Submission status: Accepted

Solution code:
def c():
    n, k = map(int, input().split())
    U = []
    for i in range(n):
        U.append(tuple(map(int, input().split())))
    U = sorted(U, key=lambda i: i[0])
    # print(U)
    for i in U:
        k -= i[1]
        if k <= 0:
            print(i[0])
            break

c()

Submission status: Accepted

Solution code:
def c():
    n, k = map(int, input().split())
    U = []
    for i in range(n):
        U.append(tuple(map(int, input().split())))
    U = sorted(U, key=lambda i: i[0])
    # print(U)
    for i in U:
        if k <= i[1]:
            print(i[0])
            break
        k -= i[1]
    else:
        print(U[-1][0])
        # if k <= 0:
        #     print(i[0])
        #     break
        # print(i, k)

c()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, K = map(int, raw_input().split())
R = [0] * (10**5+10) 

for i in xrange(N):
     ia, ib = map(int, raw_input().split())
     R[ia] += ib

k = 0
c = 0
while k < K:
    c += 1
    k += R[c]
print c

Submission status: Accepted

Solution code:
import sys

def solve():
    N, K = map(int, input().split())

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

    for i in range(N):
        ai, bi = map(int, sys.stdin.readline().split())
        cnt[ai] += bi

    tot = 0

    for i, cnti in enumerate(cnt):
        tot += cnti

        if tot >= K:
            print(i)
            return

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
r = [0]*(100000+1)
n,k = [int(x) for x in sys.stdin.readline().split()]
for i in range(n):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a] += b
c = 0
for i,j in enumerate(r):
	c += j
	if c >= k:
		print(i)
		break

Submission status: Accepted

Solution code:
import sys
r = [0]*100000
n,k = [int(x) for x in sys.stdin.readline().split()]
for i in range(n):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a-1] += b
c = 0
for i,j in enumerate(r):
	c += j
	if c >= k:
		print(i+1)
		break

Submission status: Accepted

Solution code:
n,k = map(int,raw_input().split())
l = []
s = list()
for i in range(n):
    v,count = map(int,raw_input().split())
    l.append((count,v))

l = sorted(l, key=lambda x: x[1])

countTmp = 0
for count,v in l:
    countTmp = countTmp + count
    if k <= countTmp:
       print v
       break

Submission status: Accepted

Solution code:
#N,Kの取得
N,K = list(map(int,input().split()))

#[(a_1,b_1),(a_2,b_2),...]の形でリストを作成
numList = []
for a,b in [ map(int,input().split()) for _ in range(N) ]:
	numList.append((a,b))

#作成したリストを、aの大きさで昇順ソート
numList = sorted(numList,key=lambda x:x[0])

#小さい順に要素数bを足していき、Kを超えた段階で出力、終了
count = 0
for a,b in numList:
	count += b
	if count>=K:
		print(a)
		quit()

Submission status: Accepted

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

input_data = []
for x in range(N):
    a, b = map(int, input().split())
    input_data.append([a,b])

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

Submission status: Accepted

Solution code:
import numpy as np

L = np.zeros(10**5).astype(int)
N, K = list(map(int, input().split(' ')))
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(10**5):
    tot += L[i]
    if tot >= K:
        print(i+1)
        break

Submission status: Accepted

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

count=0
for i in range(n):
    count+=list[i][1]
    if count>=k: ans=list[i][0]; break


print(ans)