結果

問題 No.5 数字のブロック
ユーザー kazuppa
提出日時 2024-06-02 07:23:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 292 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 170,756 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 02:01:14
合計ジャッジ時間 2,620 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int l,n,e=0;cin>>l>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    e+=a[i];
    if(e>l){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<n<<endl;
  return 0;
}
0