結果
問題 | No.5 数字のブロック |
ユーザー |
|
提出日時 | 2018-05-18 13:02:26 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 437 bytes |
コンパイル時間 | 1,233 ms |
コンパイル使用メモリ | 161,800 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 12:24:06 |
合計ジャッジ時間 | 2,202 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ios::sync_with_stdio(false); int l, n, a[10001]; cin >> l >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a+ n); int sum = 0,ans = 0; for (int i = 0; i < n; i++) { sum += a[i]; if (sum <=l) ans++; else break; } cout << ans << endl; return 0; }