結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2024-02-26 02:00:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 469 bytes |
| コンパイル時間 | 2,081 ms |
| コンパイル使用メモリ | 198,172 KB |
| 最終ジャッジ日時 | 2025-02-19 21:33:05 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main(){
int l,n;
cin>>l>>n;
vector<int> w(n);
rep(i,n) cin>>w[i];
sort(w.begin(),w.end());
int sum=0,ans=0;
rep(i,n){
sum+=w[i];
ans=i+1;
if(sum>l){
cout<<ans-1<<endl;
return 0;
}else if(i==w.size()-1){
break;
}
}
cout<<ans<<endl;
return 0;
}