結果

問題 No.2424 Josouzai
ユーザー InTheBloomInTheBloom
提出日時 2023-08-18 21:03:13
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 4,383 ms
コンパイル使用メモリ 178,432 KB
実行使用メモリ 10,748 KB
最終ジャッジ日時 2024-05-06 02:29:26
合計ジャッジ時間 6,661 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 19 ms
5,376 KB
testcase_05 AC 68 ms
10,680 KB
testcase_06 AC 64 ms
10,748 KB
testcase_07 AC 64 ms
10,748 KB
testcase_08 AC 66 ms
10,680 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 36 ms
10,280 KB
testcase_12 AC 25 ms
6,468 KB
testcase_13 AC 21 ms
5,376 KB
testcase_14 AC 35 ms
5,828 KB
testcase_15 AC 6 ms
5,376 KB
testcase_16 AC 57 ms
10,308 KB
testcase_17 AC 15 ms
5,376 KB
testcase_18 AC 17 ms
5,376 KB
testcase_19 AC 30 ms
5,548 KB
testcase_20 AC 58 ms
10,328 KB
testcase_21 AC 42 ms
6,568 KB
testcase_22 AC 19 ms
5,376 KB
testcase_23 AC 22 ms
5,376 KB
testcase_24 AC 10 ms
5,376 KB
testcase_25 AC 59 ms
10,552 KB
testcase_26 AC 43 ms
6,592 KB
testcase_27 AC 64 ms
10,632 KB
testcase_28 AC 55 ms
10,088 KB
testcase_29 AC 46 ms
6,976 KB
testcase_30 AC 11 ms
5,376 KB
testcase_31 AC 27 ms
5,376 KB
testcase_32 AC 60 ms
10,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main () {
    int N, K; readln.read(N, K);
    int[] A = readln.split.to!(int[]);

    A.sort;
    int ans = 0;
    long sum = 0;
    while (true) {
        if (ans == A.length || K < sum + A[ans]) {
            break;
        }
        sum += A[ans];
        ans++;
    }

    writeln(ans, " ", K-sum);
}

void read(T...)(string S, ref T args) {
    auto buf = S.split;
    foreach (i, ref arg; args) {
        arg = buf[i].to!(typeof(arg));
    }
}
0