結果

問題 No.5 数字のブロック
ユーザー HeyHey0111
提出日時 2016-02-17 21:20:18
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 401 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 64,228 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 08:16:48
合計ジャッジ時間 1,857 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> l(m);
  for(int i=0;i< m ;i++){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  int sum=0,x=0;
  while(1){
    if(sum>n){

      cout<<x-1<<endl;
      return 0;
    }
    if(x==m){
cout<<x<<endl;
return 0;
}
    sum+=l[x];
    x++;
  }
cout<<x-1<<endl;
  return 0;
}
0