Skip to content

Instantly share code, notes, and snippets.

@monhime
Created January 3, 2021 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monhime/4e29983221fc720041774ce99ec19759 to your computer and use it in GitHub Desktop.
Save monhime/4e29983221fc720041774ce99ec19759 to your computer and use it in GitHub Desktop.
ABC187 D問題 解答
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left,bisect
from itertools import accumulate
def main():
n = int(input())
AB = [tuple(map(int,input().split())) for i in range(n)]
C = [0]*n
sum_a = 0
for i, (a, b) in enumerate(AB):
C[i] = a*2 + b
sum_a += a
C.sort(reverse = True)
C = list(accumulate(C))
print(bisect(C, sum_a) + 1)
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment