Submission #6127600


Source Code Expand

Copy
#!/usr/bin/env python3
import sys


def solve(N: int, x: int, a: "List[int]"):
    ans = 0
    a.sort()
    for i in a:
        if(x-i >= 0):
            ans += 1
            x -= i
        else:
            break
    else:
        if(x > 0):
            print(ans-1)
            exit()

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, x, a)

if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task A - Candy Distribution Again
User ddtkra
Language Python3 (3.4.3)
Score 200
Code Size 851 Byte
Status
Exec Time 17 ms
Memory 3064 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 200 / 200 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt
Case Name Status Exec Time Memory
0_00.txt 17 ms 3064 KB
0_01.txt 17 ms 3064 KB
0_02.txt 17 ms 3064 KB
0_03.txt 17 ms 3064 KB
1_00.txt 17 ms 3064 KB
1_01.txt 17 ms 3064 KB
1_02.txt 17 ms 3064 KB
1_03.txt 17 ms 3064 KB
1_04.txt 17 ms 3064 KB
1_05.txt 17 ms 3064 KB
1_06.txt 17 ms 3064 KB
1_07.txt 17 ms 3064 KB