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: Wrong Answer

Solution code:
args = raw_input().split()
sarr = []
for i in range(int(args[0])):
        sarr.append(raw_input().split())

counter = 0
lim = int(args[1])

for i in range(len(sarr)):
    for j in range(i, len(sarr)-1):
        if sarr[j] > sarr[j+1]:
            temp = sarr[j]
            sarr[j] = sarr[j+1]
            sarr[j+1] = temp

#print (sarr)

for i in sarr:
    counter += int(i[1])
    if(counter >= lim):
        print(int(i[0]))
        exit()

Submission status: Wrong Answer

Solution code:
args = raw_input().split()
sarr = []
for i in range(int(args[0])):
        sarr.append(raw_input().split())

counter = 0
lim = int(args[1])

for i in sarr:
    counter += int(i[1])
    if(counter >= lim):
        print(int(i[0]))
        exit()

Submission status: Wrong Answer

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
out = field.keys()[-1]
for k in field.keys():
 kth_integer -= field[k]
 if (kth_integer < 0):
  out = k
  break
print (out)

Submission status: Wrong Answer

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
for k in field.keys():
 kth_integer -= field[k]
 if (kth_integer < 0):
  print (k)
  break

Submission status: Wrong Answer

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

arr = []
for i in range(n):
    line = raw_input().split()
    a = int(line[0])
    b = int(line[1])
    arr += [a] * b

arr = sorted(arr)
print arr[k]

Submission status: Wrong Answer

Solution code:
def main():
    n, k = [int(x) for x in input().split(' ')]
    foo = 0
    ans = None
    for _ in range(n):
        a, b = [int(x) for x in input().split(' ')]
        if (ans is None):
            foo += b
            if (foo >= k):
                ans = a
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import bisect

N, K = map(int, input().split())
array = []
for _ in range(N):
    a, b = map(int, input().split())
    idx = bisect.bisect(array, a)
    array = array[:idx] + [a]*b + array[idx:]
print(array[K])

Submission status: Wrong Answer

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()
    _k = 0
    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: Wrong Answer

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()
	_k = 0
	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)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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()
	_k = 0
	l = defaultdict(lambda: 0)
	while _k < k:
	    a,b =readLine_int_list()
	    _k += b
	print(a)
	
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
N , K = map(int,input().split())
num = 0

for i in range(N):
    x ,y = map(int,input().split())
    num = num + y
    if num >= K:
        print(x)
        sys.exit()

Submission status: Wrong Answer

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 col.items():
	count += i[1]
	if count >= K:
		print(i[0])
		break

Submission status: Wrong Answer

Solution code:
import heapq

N, K = [int(i) for i in input().split()]
a = []
for _ in range(N):
	a_i, b_i = [int(i) for i in input().split()]
	[a.append(a_i) for __ in range(b_i)]

heapq.heapify(a)
print(a[K-1])

Submission status: Wrong Answer

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+=[a]*b
print(s[k-1])

Submission status: Wrong Answer

Solution code:
from collections import deque
N, K = map(int, input().split())
a = [0] * N
b = [0] * N
x = deque()
y = deque()

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

for i in range(N):
    if len(y) <= K:
        x = [1 * a[i]] * b[i]
        y.extend(x)
    else:
        break

print(y[K-1])

Submission status: Wrong Answer

Solution code:
from collections import deque
N, K = map(int, input().split())
a = [0] * N
b = [0] * N
x = deque()

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

for i in range(N):
    for j in range(b[i]):
        if len(x) > (K - 1):
            break
        else:
            x.append(a[i])

print(x[K-1])

Submission status: Wrong Answer

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

c_n=[int(i) for k in range(N) for i in input().split()]

a_n=[]
b_n=[]
for i in range(N):
    a_n.append(c_n[2*i])
    b_n.append(c_n[2*i+1])

for i in range(N):
    for j in range(b_n[i]):
        em.append(a_n[i])

print(em[K])

Submission status: Wrong Answer

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

c_n=[int(i) for k in range(N) for i in input().split()]

a_n=[]
b_n=[]
for i in range(N):
    a_n.append(c_n[2*i])
    b_n.append(c_n[2*i+1])

for i in range(N):
    for j in range(b_n[i]):
        em.append(a_n[i])

print(em[K-1])

Submission status: Wrong Answer

Solution code:

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

l = []

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

print(sorted(l)[K])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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:
    c -= temp[t][1]
    t += 1
print(temp[t][0])

Submission status: Wrong Answer

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 k, v in sorted(d.items(), key=lambda x:x[1]):
    ans_sum += v
    if (ans_sum) >= K:
        print(k)
        break

Submission status: Wrong Answer

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 k, v in sorted(d.items(), key=lambda x:x[1]):
    ans_sum += v
    if (ans_sum) > K:
        print(k)
        break

Submission status: Wrong Answer

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 k, v in sorted(d.items(), key=lambda x:x[1]):
    if (ans_sum + v) > K:
        print(k)
        break
    ans_sum += v

Submission status: Wrong Answer

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

sum = 0
for i in range(0, n):
    sum +=nums[i][1]
    if sum > k:
        print(nums[i][0])
        break

Submission status: Wrong Answer

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 in l:
    k -= i
    if k <= 0:
        print(l.index(i))
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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)]
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: Wrong Answer

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)]
sorted(ab_list, key=lambda ab: ab[1])

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

Submission status: Wrong Answer

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

a = [0]*N
b = [0]*N
for i, ab in zip(range(N), ab_list):
    _a, _b = ab
    a[i] = _a
    b[i] = _b

idx = 0
cnt = 0
while N > cnt:
    min = 1e6
    for i in range(cnt, N):
        if min > a[i]:
            min = a[i]
            idx = i
    a_tmp = a[cnt]
    b_tmp = b[cnt]
    a[cnt] = a[idx]
    b[cnt] = b[idx]
    a[idx] = a_tmp
    b[idx] = b_tmp
    cnt += 1

print a, b

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

Submission status: Wrong Answer

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

arr = []

for i in range(N):
    arr.append(map(int, raw_input().split()))

ans = []

for i in range(N):
    tempa = arr[i][0]
    tempb = arr[i][1]

    for j in range(tempb):
        ans.append(tempa)

print ans[K - 1]

Submission status: Wrong Answer

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

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

cnt = 0
ans = 0
index = 0
while cnt < K:
    ans = a[index]
    cnt += b[index]
    index += 1

print(ans)

Submission status: Wrong Answer

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):
    c += num[k]
    if c >= K:
        d = k
        break
print(d)

Submission status: Wrong Answer

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番目の要素でソート

    ans = src[0][0]
    cnt = 0

    for a, b in src:
        cnt += cnt + b
        ans = a
        if cnt > k:
            return ans
            break

    return ans

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

Submission status: Wrong Answer

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


diffK=x[1]

for i in range(1,x[0]+1):
    if diffK-v[i]<=0:
        print(i)

        quit()
    else:
        diffK -=v[i]

Submission status: Wrong Answer

Solution code:
inf=float('inf')

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


diffK=x[1]
for i in a:
    i=list(map(int, i.split()))

    if diffK-i[1]<=0:
        print(i[0])
        quit()
    else:
        diffK -=i[1]

Submission status: Wrong Answer

Solution code:
inf=float('inf')

#n = int(input())
x = list(map(int, input().split()))
a=[input() for i in range(x[0])]


diffK=x[1]
for i in a:
    i=list(map(int, i.split()))

    if diffK-i[1]<=0:
        print(i[0])

        quit()
    else:
        diffK -=i[1]

Submission status: Wrong Answer

Solution code:
inf=float('inf')


x = list(map(int, input().split()))
a=[input() for i in range(x[0])]


diffK=x[1]
for i in a:
    i=list(map(int, i.split()))
    print(i)
    if diffK-i[1]<=0:
        print(i[0])
        quit()
    else:
        diffK -=i[1]

Submission status: Wrong Answer

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

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

A = []

while True:
    a, b = map(int,input().split())
    B = [a for j in range(b)]
    A.extend(B)
    if len(A) >= K:
        print(A[K-1])
        break

Submission status: Wrong Answer

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

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

A = []

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

Submission status: Wrong Answer

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

lis = [];
for i in range(N):
    a,b = input().split()
    for j in range(int(b)):
        lis.append(int(a))
print(str(lis[K-1]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
times, target = map(int, input().split())
ans = -1
array = []
for i in range(times):
    a, b = map(int, input().split())
    if ans == -1:
        if len(array) >= a:
            array[a-1]= array[a-1] + b
        else:
            array.insert(a,b)

        if sum(array) >= target:
            sum = 0
            for index, j in enumerate(array):
                sum += j
                if sum >= target:
                    ans = index+1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
times, target = map(int, input().split())
ans = -1
array = []
for i in range(times):
    a,b = map(int,input().split())
    if ans == -1 :
        array += [a for i in range(b)]
        if len(array) >= target:
            array.sort()
            ans = array[target-1]
print(ans)

Submission status: Wrong Answer

Solution code:
times, target = map(int, input().split())
sum = 0
ans = -1
for i in range(times):
    a,b = map(int,input().split())
    if ans == -1 :
        if sum + b >= target:
            ans = a
        else:
            sum += b

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
N, K = map(int, input().split())
a=[];
b=[];

for i in range(N):
    c, d= map(int, input().split())
    a.append(c)
    b.append(d)
f=[]
for i in range(N):
    g=b[i]
    e=[a[i]]*g
    f.append(e)
#2次元を1次元にする
merged = list(itertools.chain(*f))
#print(merged)
print(merged[K-1])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N, K = ILI()
    nums = IAI(N)
    return (N, K, nums)


def solve(N, K, nums):
    count = 0
    ans = nums[0][0]
    for num in nums:
        count += num[1]
        ans = num[0]
        if count >= K:
            break
    
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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 num[i]
        break

Submission status: Wrong Answer

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

#タイムアウト問題。リストをソートし、K後を削除する。
#空リストを作成。a,bを把握し、リストにaを追加、b回。これをN回くりかえし
l3 = []
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	if len(l3) > K and max(l3) < a:
		pass
	else:
		for j in range(K):
			l3.append(a)

# リストをソートし、K番目を出力
l3.sort()
print(str(l3[K-1]))

Submission status: Wrong Answer

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

#タイムアウト問題。リストをソートし、K後を削除する。
#空リストを作成。a,bを把握し、リストにaを追加、b回。これをN回くりかえし
l3 = []
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	if len(l3) > K and max(l3) < b:
		pass
	else:
		for j in range(K):
			l3.append(a)

# リストをソートし、K番目を出力
l3.sort()
print(str(l3[K-1]))

Submission status: Wrong Answer

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

#空リストを作成。a,bを把握し、リストにaを追加、b回。これをN回くりかえし
l3 = []
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	for j in range(b):
		l3.append(a)

# リストをソートし、K番目を出力
l3.sort()
print(str(l3[K]))

Submission status: Wrong Answer

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])
    else:
        K -= tup[1]

Submission status: Wrong Answer

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

array = []
count = 0
while len(array) < K and count < N:
    a, b = [int(x) for x in input().split()]
    array.extend([a for x in range(b)])
    count += 1

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

Submission status: Wrong Answer

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

array = []
count = 0
while len(array) < K and count < N:
    a, b = [int(x) for x in input().split()]
    array.extend([a for x in range(b)])
    count += 1

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

Submission status: Wrong Answer

Solution code:
d = []
n, k = map(int, input().split())
data = [[int(i) for i in input().split()] for i in range(n)]
for i in data:
    for j in range(i[1]):
        d.append(i[0])
d.sort()
print(d[k])

Submission status: Wrong Answer

Solution code:
d = []
n, k = map(int, input().split())
data = [[int(i) for i in input().split()] for i in range(n)]
for i in data:
    for j in range(i[1]):
        d.append(i[0])
print(d[k])

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
print(n)
total = 0
for i in range(n):
    a, b = map(int, input().split())
    total = total + b
    if total >= k:
        print(a)
        exit()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

ans, cnt = -1, 0
for x in li:
    ans = x
    cnt += di[x]
    if cnt >= k:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

ans, cnt = -1, 0
for x in li:
    if cnt >= k:
        break
    ans = x
    cnt += di[x]

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

ans, cnt = -1, 0
for x in li:
    if cnt > k:
        break
    ans = x
    cnt += di[x]

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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(N):
	sm += L[i]
	if sm >= K:
		print(i + 1)
		break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
table = input().split()
N,K = int(table[0]),int(table[1])
preA,preB = [],[]
l = 1
while l <= N:
    a = input().split()
    a = list(map(int,a))
    if sum(preB) < K:
        preA += [a[0]]
        preB += [a[1]]
    l += 1
print(preA[-1])

Submission status: Wrong Answer

Solution code:
table = input().split()
N,K = int(table[0]),int(table[1])
preA,preB = [],[]
l = 1
while l <= N:
    a = input().split()
    a = list(map(int,a))
    if sum(preB) < K:
        preA += [a[0]]
        preB += [a[1]]
    l += 1
s = len(preA)
hairetu = []
i = 0
while i <= s-1:
    for j in range(0, preB[i]):
        hairetu += [preA[i]]
    i += 1
hairetu = list(map(int,hairetu))
hairetu.sort()
print(hairetu[K-1])

Submission status: Wrong Answer

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

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

out = []

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

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

Submission status: Wrong Answer

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

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

out = []

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

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

Submission status: Wrong Answer

Solution code:
table = input().split()
N,K = int(table[0]),int(table[1])
preA,preB = [],[]
for i in range(0,N):
    a = input().split()
    preA += [a[0]]
    preB += [a[1]]
hairetu = []
i = 0
while i <= N-1:
    for j in range(0,int(preB[i])):
        hairetu += [preA[i]]
    if len(hairetu) <= K-1:
        i += 1
    else:
        break
hairetu = list(map(int,hairetu))
hairetu.sort()
print(hairetu[K-1])

Submission status: Wrong Answer

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 -= 1
        if k <= 0:
            print(i[0])
            break
            
c()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def c():
    n, k = map(int, input().split())
    U = []
    for i in range(n):
        U.append(tuple(map(int, input().split())))
    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: Wrong Answer

Solution code:
def c():
    n, k = map(int, input().split())
    U = []
    for i in range(n):
        U.append(tuple(map(int, input().split())))
    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: Wrong Answer

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

c()

Submission status: Wrong Answer

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

c()

Submission status: Wrong Answer

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

c()

Submission status: Wrong Answer

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

c()

Submission status: Wrong Answer

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

sorted(U, key=lambda i: i[0])
for i in U:
    k -= i[1]
    print(i, k)
    if k <= 0:
        print(i[0])

Submission status: Wrong Answer

Solution code:
nk = [int(i) for i in input().split()]
n = nk[0]
k = nk[1]
array = []
for i in range(n):
    num = input().split()
    a = num[0]
    b = int(num[1])
    k -= b
    array.append(a)
    if k <= 0:
        break
    else:
        array.pop()
print(array[0])

Submission status: Wrong Answer

Solution code:
nk = [int(i) for i in input().split()]
n = nk[0]
k = nk[1]
array = []
for i in range(n):
    num = input().split()
    a = num[0]
    array.append(a)
    b = int(num[1])
    k -= b 
    if k <= 0:
        print(a)
        break

Submission status: Wrong Answer

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

c()

Submission status: Wrong Answer

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

c()

Submission status: Wrong Answer

Solution code:
def c():
    n, k = map(int, input().split())
    U = {}
    for i in range(n):
        ai, bi = map(int, input().split())
        if ai in U:
            U[ai] += bi
        else:
            U[ai] = bi
    U = list(U.items())
    sorted(U, key=lambda i: i[0])
    # print(U)
    for j in U:
        k -= j[1]
        if k <= 0:
            print(j[0])
            return
    print(U[-1][0])
    pass

c()

Submission status: Wrong Answer

Solution code:
def c():
    n, k = map(int, input().split())
    U = {}
    for i in range(n):
        ai, bi = map(int, input().split())
        if ai in U:
            U[ai] += bi
        else:
            U[ai] = bi
    U = list(U.items())
    sorted(U, key=lambda i: i[0])
    # print(U)
    for j in U:
        k -= j[1]
        if k <= 0:
            print(j[0])
            return
    pass

c()

Submission status: Wrong Answer

Solution code:
def c():
    n, k = map(int, input().split())
    U = {}
    for i in range(n):
        ai, bi = map(int, input().split())
        if ai in U:
            U[ai] += bi
        else:
            U[ai] = bi
    U = list(U.items())
    sorted(U, key=lambda i: i[0])
    print(U)
    for j in U:
        k -= j[1]
        if k <= 0:
            print(j[0])
            return
    pass

c()

Submission status: Wrong Answer

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

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: Wrong Answer

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])
sorted_data = sorted(input_data, key=lambda x:input_data[0])

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
def c():
    n, k = map(int, input().split())
    U = []
    for i in range(n):
        ai, bi = map(int, input().split())
        U.extend([ai]*bi)
    sorted(U)
    print(U[k-1])
    pass

c()