結果

問題 No.2424 Josouzai
ユーザー kuroni
提出日時 2023-08-18 21:13:25
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 2,599 ms
コンパイル使用メモリ 249,252 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 05:09:11
合計ジャッジ時間 4,345 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k; cin >> n >> k;
    vector<int> a(n + 1); a[n] = numeric_limits<int>::max();
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i <= n; i++) {
        if (a[i] > k) {
            return cout << i << " " << k, 0;
        } else {
            k -= a[i];
        }
    }
}
0