結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
Lay_ec
|
| 提出日時 | 2014-11-12 16:30:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 615 bytes |
| コンパイル時間 | 642 ms |
| コンパイル使用メモリ | 78,796 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 22:01:07 |
| 合計ジャッジ時間 | 1,473 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <cctype>
#include <queue>
using namespace std;
typedef pair<int,int> pii;
const int INF=(1<<30);
int main(){
int L,N;
cin>>L>>N;
vector<int> W(N);
for(int i=0;i<N;i++){
cin>>W[i];
}
sort(W.begin(),W.end());
int res=0;
for(int i=0;i<N;i++){
if(L-W[i]>=0){
res++;
L-=W[i];
}else break;
}
cout<<res<<endl;
return 0;
}
Lay_ec