結果

問題 No.2424 Josouzai
ユーザー ebi_fly
提出日時 2023-08-11 18:31:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 1,821 ms
コンパイル使用メモリ 197,772 KB
最終ジャッジ日時 2025-02-16 00:46:10
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = std::int64_t;

int main() {
    int n;
    i64 k;
    std::cin >> n >> k;
    std::vector<i64> a(n);
    for (auto &x : a) std::cin >> x;
    std::sort(a.begin(), a.end());
    int ans = 0;
    for (auto x : a) {
        if (x <= k) {
            k -= x;
            ans++;
        } else
            break;
    }
    std::cout << ans << " " << k << '\n';
}
0