結果
問題 | No.2424 Josouzai |
ユーザー |
|
提出日時 | 2023-08-19 03:30:38 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 98 ms / 2,000 ms |
コード長 | 500 bytes |
コンパイル時間 | 2,199 ms |
コンパイル使用メモリ | 165,396 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-28 16:49:26 |
合計ジャッジ時間 | 6,122 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
#include <bits/stdc++.h>#define int long long#define all(x) (x).begin(),(x).end()using namespace std;signed main(){int n, k; cin >> n >> k;vector<int> a(n);for (int i = 0; i < n; i ++ ) cin >> a[i];sort(all(a));for (int i = 1; i < n; i ++ ) a[i] += a[i - 1];int out = -1;for (int i = 0; i < n; i ++ ){if (a[i] > k){out = i;break;}}if (out == -1) cout << n << " " << k - a[n - 1] << endl;else cout << out << " " << (out ? k - a[out - 1] : k) << endl;}