結果

問題 No.5 数字のブロック
ユーザー fuu32
提出日時 2017-10-29 14:16:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 1,618 ms
コンパイル使用メモリ 171,920 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 11:48:31
合計ジャッジ時間 2,546 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define UB upper_bound
#define LB lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int l,n;
  cin>>l>>n;
  vector<int> w(n);
  REP(i,n)cin>>w[i];
  sort(ALL(w));
  int ans=0;
  REP(i,n){
    if(l-w[i]>=0){
      ans++;
      l-=w[i];
    }else{
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}
0