結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2016-07-12 07:54:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 384 bytes |
| コンパイル時間 | 574 ms |
| コンパイル使用メモリ | 66,236 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-18 08:45:06 |
| 合計ジャッジ時間 | 1,660 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int l,n,w;
cin>>l;
cin>>n;
vector<int> v;
for(int i=0; i<n; ++i){
cin>>w;
v.push_back(w);
}
sort(v.begin(),v.end());
int x;
x=0;
for(int i=0; i<n; ++i){
if(l>=v[i]){
l-=v[i];
x++;
} else {
break;
}
}
cout<<x<<endl;
return 0;
}