結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2019-08-29 12:33:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 368 bytes |
| コンパイル時間 | 833 ms |
| コンパイル使用メモリ | 78,572 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-17 16:49:39 |
| 合計ジャッジ時間 | 1,928 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;
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 sum=0;
int ans=0;
for(int i=0;i<n;i++){
if(sum+w[i]<=l){
sum+=w[i];
ans++;
}
}
cout << ans << endl;
}