結果
問題 | No.5 数字のブロック |
ユーザー | FVRChan |
提出日時 | 2017-07-27 07:59:38 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 301 bytes |
コンパイル時間 | 544 ms |
コンパイル使用メモリ | 60,548 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 11:31:53 |
合計ジャッジ時間 | 1,517 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include<iostream> #include<string> #include<algorithm> #include<utility> using namespace std; int main(void){ int l,n,sum=0,*w; cin>>l>>n; w=new int[n]; for(int i=0;i<n;i++)cin>>w[i]; sort(w,w+n); int i; for(i=0;i<n;i++){ if(sum+w[i]<=l)sum+=w[i]; else{ break; } } cout<<i<<endl; }