結果

問題 No.2424 Josouzai
ユーザー mono_0812mono_0812
提出日時 2023-08-18 21:01:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 3,105 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 34,868 KB
最終ジャッジ日時 2024-05-06 02:26:10
合計ジャッジ時間 5,068 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
12,288 KB
testcase_01 AC 37 ms
12,288 KB
testcase_02 AC 36 ms
12,416 KB
testcase_03 AC 37 ms
12,416 KB
testcase_04 AC 74 ms
18,764 KB
testcase_05 AC 167 ms
34,744 KB
testcase_06 AC 171 ms
34,360 KB
testcase_07 AC 166 ms
34,456 KB
testcase_08 AC 170 ms
34,868 KB
testcase_09 AC 38 ms
12,416 KB
testcase_10 AC 58 ms
17,840 KB
testcase_11 AC 108 ms
29,608 KB
testcase_12 AC 97 ms
24,780 KB
testcase_13 AC 77 ms
18,788 KB
testcase_14 AC 107 ms
24,168 KB
testcase_15 AC 48 ms
14,080 KB
testcase_16 AC 155 ms
32,032 KB
testcase_17 AC 64 ms
17,056 KB
testcase_18 AC 69 ms
18,112 KB
testcase_19 AC 98 ms
22,916 KB
testcase_20 AC 153 ms
31,424 KB
testcase_21 AC 125 ms
27,660 KB
testcase_22 AC 73 ms
18,676 KB
testcase_23 AC 85 ms
20,168 KB
testcase_24 AC 56 ms
15,736 KB
testcase_25 AC 159 ms
34,392 KB
testcase_26 AC 122 ms
27,060 KB
testcase_27 AC 163 ms
33,940 KB
testcase_28 AC 143 ms
30,308 KB
testcase_29 AC 131 ms
29,808 KB
testcase_30 AC 60 ms
16,056 KB
testcase_31 AC 89 ms
21,752 KB
testcase_32 AC 157 ms
33,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

############################################################################################
import bisect,collections,copy,heapq,itertools,math,string,sys,queue,time,random
from decimal import Decimal
def I(): return input()
def IS(): return input().split()
def II(): return int(input())
def IIS(): return list(map(int,input().split()))
def LIIS(): return list(map(int,input().split()))

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

import math

def prime_numbers(n):
    prime = [True for i in range(n+1)]
    prime[0] = False
    prime[1] = False

    sqrt_n = math.ceil(math.sqrt(n))
    for i in range(2, sqrt_n):
        if prime[i]:
            for j in range(2*i, n+1, i):
                prime[j] = False
    numbers=[]
    for i in range(2,n+1):
        if prime[i]:
            numbers.append(i)

    return numbers

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==[] and n>1:
        arr.append([n, 1])
 
    return arr
from collections import defaultdict


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        group_members = defaultdict(list)
        for member in range(self.n):
            group_members[self.find(member)].append(member)
        return group_members

    def __str__(self):
        return '\n'.join(f'{r}: {m}' for r, m in self.all_group_members().items())
 
INF=10**18
MOD=998244353
MOD2=10**9+7
sys.setrecursionlimit(500005)
def bit_count(x):
    return bin(x).count("1")
def yesno(f):
    if f:print("Yes")
    else:print("No")
dxy=((1,0),(0,-1),(-1,0),(0,1))
##################################################################
n,k=IIS()
A=LIIS()
A.sort()
ans=0
for i in A:
    if k>=i:
        k-=i
        ans+=1
print(ans,k)
0