結果

問題 No.5 数字のブロック
ユーザー mytkyt
提出日時 2018-03-27 20:07:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 369 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 59,128 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 12:51:54
合計ジャッジ時間 1,813 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;

int main(){
  int L,N,sum=0,count=0;
  cin >> L >> N;
  int block[N];
  for(int i=0; i<N; i++){
    cin >> block[i];
  }
  sort(block, block + N);
  for(int i=0; sum<L; i++){
    sum+=block[i];
    count++;
  }
  if(sum==L){
    cout << count << endl;
  }else{
    cout << count-1 << endl;
  }
  return 0;
}
0