結果

問題 No.5 数字のブロック
ユーザー shoshosho
提出日時 2019-08-14 16:04:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 397 bytes
コンパイル時間 1,152 ms
コンパイル使用メモリ 161,280 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 14:29:40
合計ジャッジ時間 2,102 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main() {

  int l,n;cin>>l>>n;
  int w[n+10];rep(i,0,n)cin>>w[i];

  sort(w,w+n);
  int sum=0;
  rep(i,0,n){
    sum+=w[i];
    if(sum>l){
      out(i);
      return 0;
    }
  }
  out(n);


  return 0;
}
0