Created
January 3, 2021 01:15
-
-
Save monhime/4e29983221fc720041774ce99ec19759 to your computer and use it in GitHub Desktop.
ABC187 D問題 解答
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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