結果

問題 No.5 数字のブロック
ユーザー himawariscience
提出日時 2019-03-21 18:36:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 298 bytes
コンパイル時間 1,739 ms
コンパイル使用メモリ 169,700 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 13:05:31
合計ジャッジ時間 2,793 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int L,N;
  cin >> L >> N;
  int W[N];
  for(int i = 0;i < N;i++) cin >> W[i];
  
  sort(W,W+N);
  int count = 0, ans = 0;
  
  for(int i = 0;i < N;i++){
    count += W[i];
    if(count > L) break;
    else ans++;
  }
  cout << ans;
  
}
0