結果

問題 No.5 数字のブロック
ユーザー AkabaEriAkabaEri
提出日時 2020-03-27 16:21:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 314 bytes
コンパイル時間 1,796 ms
コンパイル使用メモリ 164,140 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 08:39:28
合計ジャッジ時間 2,615 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
       

int main(){
  int L,n;
  cin >> L >> n;
  int a[n];
  int ans=0;
  for(int i=0;i<n;i++){cin >> a[i];}
  sort(a,a+n);
  for(int i=0;i<n;i++){
    L-=a[i];
    if(L>=0)ans++;
    if(L<0)break;
  }
  cout << ans << endl;
}
0