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:
def answer(arr, k):
    for a, b in arr:
        if k > b:
            k -= b
        else:
            return a

n, k = map(int, input().split())
arr = []
for i in range(n):
    a, b = map(int, input().split())
    if k > b:
        k -= b
    else:
        print(a)
        exit()

Submission status: Wrong Answer

Solution code:
def answer(arr, k):
    for a, b in arr:
        if k > b:
            k -= b
        else:
            return a

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

Submission status: Wrong Answer

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

counter = {}

for _ in range(N):
    a, b = [int(i) for i in input().split()]
    counter.setdefault(a, 0)
    counter[a] += b
    
counter2 = [0]
output = 0
counter_sorted = sorted(counter.items())
counter_sorted = [v[1] for v in counter_sorted]

for i in counter_sorted:
    counter2.append(counter2[-1]+i)

for i in range(1, len(counter2)):
    if K <= counter2[i]:
        output = i
        break
print(output)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

k=K
for n in range(N):
  a,b = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7
  if k>b:
    k -= b
  else:
    print(a)
    exit(0)

Submission status: Wrong Answer

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

tmp = 0
i = -1
while tmp < k:
    i += 1
    tmp += s[i][1]
    

print(s[i][0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0
ans = 0

for i in range(n):
    a, b = map(int, input().split())
    cnt += b
    if cnt >= k and ans == 0:
        ans = a

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = input().strip().split()
N, M = [int(N), int(M)]

# 2次元配列
ab = sorted(list(map(int, input().split())) for _ in range(N))
c=0
for a,b in ab:
    c+=b
    if c>=M:
        print(a)

Submission status: Wrong Answer

Solution code:
N, M = input().strip().split()
N, M = [int(N), int(M)]

# 2次元配列
ab = sorted(list(map(int, input().split())) for _ in range(N))
c=0
for a,b in ab:
    c+=b
    if c==M:
        print(a)

Submission status: Wrong Answer

Solution code:
N, M = input().strip().split()
N, M = [int(N), int(M)]

# 2次元配列
grid = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    grid.append(array)
a=[]
for i in range(N):
    for j in range(grid[i][1]):
        a.append(grid[i][0])
print(a[M-1])

Submission status: Wrong Answer

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

count = 0
ans = set()
for a, b in ab:
    ans.add(a)
    count += b
    if count >= k:
        break

print(list(ans)[-1])

Submission status: Wrong Answer

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

count = 0
for a, b in ab:
    ans = a
    count += b
    if count >= k:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
list = []
for i in range(N):
    a,b = map(int,input().split())
    for j in range(b):
        list.append(a)
print(list[K-1])

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
A=[]
tmp=k
for i in range(n):
    a,b=map(int,input().split())
    tmp-=b
    if tmp<=0:
        print(a)
        sys.exit()

Submission status: Wrong Answer

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

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

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:
n,k = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
import fractions
import sys
from functools import reduce
import collections
import time
input = sys.stdin.readline


def main():
    n, k = input_list()
    total = 0
    for _ in range(n):
        num, count = input_list()
        pre = total
        total += count
        if pre <= k <= total:
            print(num)
            exit(0)


def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N,K = IL()
count = 0
while True:
  a,b = IL()
  count += b
  if count>=K:
    PE(a)

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N,K = IL()
d = []
for _ in range(N):
  a,b = IL()
  d+= [a]*b
  
P(d[K-1])

Submission status: Wrong Answer

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

for k,v in result.items():
    if K > v:
        K -= v
    else:
        print(k)
        exit()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
for j in range(N):
    K -= B[j]
    if K <= 0:
        print(A[j])
        exit()

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
maxa = 0
maxb = 0
while K > 0:
    a, b = map(int, input().split())
    if maxa <= a:
        maxa = a
        maxb = b
        K -= maxb
    else:
        K -= b
print(maxa)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ans = 0
while K > 0:
    a, b = map(int, input().split())
    K -= b
    ans = a
print(a)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ans = 0
while N >= 0:
    a, b = map(int, input().split())
    N -= b
    ans = a

print(ans)

Submission status: Wrong Answer

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

cnt=[0 for _ in range(10**5)]
for j in range(N):
    a,b=map(int,input().split())
    cnt[a-1]+=b

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split()) #a1 a2 a3

com = [list(map(int, input().split())) for _ in range(n)]

i=0

while k>0:
  k-=com[i][1]
  i+=1

print(com[~-i][0]) #~-i i-1

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int, input().split()) #a1 a2 a3

com = [list(map(int, input().split())) for _ in range(n)]

bcnt=icnt=0

for ab in com:
  icnt+=1
 
  if bcnt+ab[1]<k:
    bcnt+=ab[1]
  else:
    print(ab[0])
    sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int, input().split()) #a1 a2 a3

com = [list(map(int, input().split())) for _ in range(n)]

bcnt=icnt=0

for ab in com:
  icnt+=1
  if icnt==n:
    print(ab[1])
    sys.exit(0)
  
  if bcnt+ab[1]<k:
    bcnt+=ab[1]
  else:
    print(ab[0])
    sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int, input().split()) #a1 a2 a3

com = [list(map(int, input().split())) for _ in range(n)]

bcnt=icnt=0

for ab in com:
  icnt+=1
  if icnt==n:
    print(ab[1])
    sys.exit(0)
  
  if bcnt+ab[1]<=k:
    bcnt+=ab[1]
    preab=ab[0]
  else:
    if icnt==1:
      print(ab[0])
      sys.exit(0)
    print(preab)
    sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int, input().split()) #a1 a2 a3

com = [list(map(int, input().split())) for _ in range(n)]

bcnt=icnt=0

for ab in com:
  icnt+=1
  if icnt==n:
    print(ab[1])
    sys.exit(0)
  


  if bcnt+ab[1]<=k:
    if icnt==1:
      print(ab[0])
      sys.exit(0)

    bcnt+=ab[1]
    preab=ab[0]
  else:
    print(preab)
    sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int, input().split()) #a1 a2 a3

com = [list(map(int, input().split())) for _ in range(n)]

bcnt=icnt=0

for ab in com:
  icnt+=1
  if icnt==n:
    print(ab[1])
    sys.exit(0)

  if bcnt+ab[1]<k:
    bcnt+=ab[1]
    preab=ab[0]
  else:
    print(preab)
    sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int, input().split()) #a1 a2 a3

com = [list(map(int, input().split())) for _ in range(n)]

bcnt=icnt=0

for ab in com:
  icnt+=1
  if icnt==n:
    print(ab[1])
    sys.exit(0)

  if bcnt+ab[1]<k:
    bcnt+=ab[1]
    preab=ab[0]
  else:
    print(preab)

Submission status: Wrong Answer

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

abb = sorted(ab)
temp =0

for i in range(n):
    if temp < k:
        temp += abb[i][1]
    else:
        print(abb[i-1][0])
        exit()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
memo = {}
len_arr = 0

for _ in range(N):
    ai, bi = map(int, input().split())
    len_arr += bi
    memo[len_arr] = ai

len_arr_list = sorted(memo.keys())

for boundary in len_arr_list:
    if K <= boundary:
        print(memo[boundary])
        break

Submission status: Wrong Answer

Solution code:
def invr():
    return(map(int, input().split()))


n, k = invr()
arr = []
d = dict()
for i in range(n):
    a, b = invr()
    if a in d:
        d[a] += b
    else:
        d[a] = b
    arr.append(a)
arr = sorted(arr)
pos = 0
for i in arr:
    pos += d[i]
    if pos >= k:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def invr():
    return(map(int, input().split()))


n, k = invr()
arr = []
d = dict()
for i in range(n):
    a, b = invr()
    d[a] = b
    arr.append(a)

arr = sorted(arr)
pos = 1
for i in arr:
    pos += d[i]
    if pos > k:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def invr():
    return(map(int, input().split()))


n, k = invr()
arr = []
d = dict()
for i in range(n):
    a, b = invr()
    d[a] = b
    arr.append(a)

arr = sorted(arr)
pos = 1
for i in arr:
    pos += d[i]
    if pos >= k:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def invr():
    return(map(int, input().split()))


n, k = invr()
arr = []
d = dict()
for i in range(n):
    a, b = invr()
    d[a] = b
    arr.append(a)

arr = sorted(arr)
pos = 0
for i in arr:
    pos += d[i]
    if pos >= k:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    count1 = 0
    count2 = 0
    d = []
    l = {}
    
    for i in range(N):
        a,b = map(int, input().split())
        if not a in d:
            d.append(a)
            l[a] = b
        else:
            l[a] += b
        count1 += b
        if count1 >= K:
            break
    d.sort()
    for i in d:
        count2 += l[i]
        if count2 >= K:
            print(i)
            break
        

        

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    count = 0
    d = []
    l = {}
    for i in range(N):
        a,b = map(int, input().split())
        d.append(a)
        l[a] = b
    d.sort()
    
    for i in d:
        count += l[i]
        if count >= K:
            print(i)
            break
        

        

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    count = 0
    l = []
    
    for _ in range(N):
        a, b = map(int, input().split())
        count += b
        l.append(a)
        
        if count >= K:
            break
    
    l.sort()

    print(l[-1])
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

d_sorted = dict(sorted(d.items(),key=lambda x:int(x[0])))
now = 0
for num,cnt in d_sorted.items():
  now += cnt
  if now >= k:
    print(num)
    exit()

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
d = dict()
for _ in range(n):
  a,b = input().split()
  b = int(b)
  if a in d.keys():
    d[a] += b
  else:
    d[a] = b
d_sorted = dict(sorted(d.items(),key=lambda x:x[0]))
now = 0
for num,cnt in d_sorted.items():
  now += cnt
  if now >= k:
    print(num)
    exit()

Submission status: Wrong Answer

Solution code:
from collections import deque

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

while K > 0:
  a, b = d.popleft()
  K -= b

print(a)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,k=mii()
cnt=0

for i in range(n):
    a,b=mii()
    if cnt<k<=cnt+b:
        print(a)
        exit()
    cnt+=b

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
N, K = map(int, input().split())

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

total = 0
for k, v in dict(sorted(cnt.items())).items():
    total += v
    if total >= K:
        print(k)
        exit()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
N, K = map(int, input().split())

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

cnt = dict(sorted(cnt.items()))
total = 0
for k, v in cnt.items():
    total += v
    if total >= K:
        print(k)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

for i in range(N):
    K -= n[i]
    if K <= 0:
        print(i+1)
        break

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import accumulate

    n, k, *ab = map(int, open(0).read().split())
    a = list(accumulate(ab[1::2]))
    b = ab[::2]
    for x, y in zip(a, b):
        if k <= x:
            print(y)
            break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import accumulate
    from bisect import bisect_left
    n, k, *ab = map(int, open(0).read().split())
    a = list(accumulate(ab[1::2]))
    b = ab[::2]
    i = bisect_left(a, k)
    ans = b[i]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    a, b = [0 for i in range(n)], [0 for i in range(n)]
    for i in range(n):
        a[i], b[i] = [int(x) for x in input().split()]
    ans = solve(n, k, a, b)
    print(ans)


def solve(n, k, a, b):
    back = 0
    for i in range(n):
        back += b[i]
        if back >= k:
            return a[i]
    return 


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
lists = []
cnt = 0
flag = 0
a_b = [list(map(int,input().split())) for i in range(n)]
for a,b in a_b:
    cnt += b
    if cnt >= k:
        print(a)
        exit()

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
lists = []
cnt = 0
flag = 0
for i in range(n):
    a,b = map(int,input().split())
    cnt += b
    if cnt >= k and flag == 0:
        ans = a
        flag = 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
m = 0

for i in range(N):

    a,b = map(int,input().split())
    K -= b
    m = max(m,a)
    if K <= 0:
        print(m)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int,input().split())
    L=[list(map(int,input().split())) for i in range(n)]
    L=sorted(L, key=lambda x: x[0])
    
    
    cnt=0
    for i in range(n):
        temp=cnt
        cnt+=L[i][1]
        if cnt==k: print(L[i][0])
        elif cnt>k and temp<k:
            print(L[i][0])
            break
        elif cnt>k and temp>=k:
            print(L[i-1][0])
            break

    
resolve()

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

def main():
    n,k = readInts()
    sum_ = 0
    while sum_ < k:
        a,b = readInts()
        if sum_ + b >= k:
            print(a)
            exit()
        sum_ += b
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int,input().split())
    L=[list(map(int,input().split())) for i in range(n)]
    L=sorted(L, key=lambda x: x[0])
    
    
    cnt=0
    for i in range(n):
        temp=cnt
        cnt+=L[i][1]
        if cnt>k and temp<k:
            print(L[i][0])
            break
        elif cnt>k and temp>=k:
            print(L[i-1][0])
            break

    
resolve()

Submission status: Wrong Answer

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

ans = 0
flag = True
m = 0
for i in range(N):
    a,b = map(int,input().split())
    K -= b
    m = max(m,a)
    if K <= 0 and flag:
        ans = m
        flag = False

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int,input().split())
    A, B = [0] * n, [0] * n
    for i in range(n):
        A [i], B [i] = map(int, input().split())
    
    cnt=0
    for i in range(n):
        temp=cnt
        cnt+=B[i]
        if cnt>k and temp<k:
            print(A[i])
            break
        elif cnt>k and temp>=k:
            print(A[i-1])
            break

    
resolve()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,k=MI()
lis=[0 for i in range(10**5)]
for i in range(n):
    a,b=MI()
    lis[a-1]+=b
#print(lis)
sm=0
for i in range(n):
    sm+=lis[i]
    if sm>=k:
        print(i+1)
        sys.exit()

Submission status: Wrong Answer

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

ans = 0
flag = True
for i in range(N):
    a,b = map(int,input().split())
    K -= b
    if K < 0 and flag:
        ans = a
        flag = False

print(ans)

Submission status: Wrong Answer

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

ans = 0
flag = True
for i in range(N):
    a,b = map(int,input().split())
    K -= b
    if K <= 0 and flag:
        ans = a
        flag = False

print(ans)