結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2016-03-21 23:12:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 446 bytes |
| コンパイル時間 | 525 ms |
| コンパイル使用メモリ | 64,336 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 08:22:27 |
| 合計ジャッジ時間 | 1,508 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
int l,n;
std::cin >> l >> n;
std::vector<int> w(n);
for (int i = 0; i < n; i++) {
std::cin >> w[i];
}
std::sort(w.begin(),w.end());
int ans = 0;
int sum = 0;
for (int k = 0; k < n ; k++) {
sum += w[k];
if (sum <= l) ans++;
else break;
}
std::cout << ans << std::endl;
return 0;
}