結果
| 問題 | No.156 キャンディー・ボックス |
| コンテスト | |
| ユーザー |
Jikky1618
|
| 提出日時 | 2025-09-03 07:27:49 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| + 508µs | |
| コード長 | 543 bytes |
| 記録 | |
| コンパイル時間 | 2,181 ms |
| コンパイル使用メモリ | 340,520 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-14 13:42:15 |
| 合計ジャッジ時間 | 3,988 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...)
#endif
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
int N, M;
cin >> N >> M;
vector<int> C(N);
for (int i = 0; i < N; i++) cin >> C[i];
ranges::sort(C);
int sum = 0;
for (int i = 0; i < N; i++) {
sum += C[i];
if (sum >= M) {
cout << i + (sum == M) << '\n';
return 0;
}
}
}
Jikky1618