結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2017-06-19 16:55:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 475 bytes |
コンパイル時間 | 732 ms |
コンパイル使用メモリ | 60,676 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-10-02 07:44:17 |
合計ジャッジ時間 | 1,630 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 4 |
ソースコード
#include <iostream> #include <string> #include <algorithm> using namespace std; int main() { int l, n; cin >> l >> n; int w[10005]={}; for(int i=0; i<n; i++){ cin >> w[i]; } sort(w, w+n); reverse(w, w+n); int sum, ans=0; for(int i=0; i<n;i++){ sum = 0; int j; for(j=i; j<n && sum<=l; j++){ sum += w[j]; } ans = max(ans, j-i); } cout << ans << endl; return 0; }