結果

問題 No.5 数字のブロック
ユーザー focusfocus
提出日時 2018-01-30 18:19:16
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 437 bytes
コンパイル時間 942 ms
コンパイル使用メモリ 69,000 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-18 11:59:39
合計ジャッジ時間 1,720 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;
int main(){
    long long L,N,x,i=0,ans=0;
    vector<long long> vc;
    cin >> L >> N;
    while(N--){
        cin >> x;
        vc.push_back(x);
    }
    sort(vc.begin(),vc.end());
    for(i=0;i<vc.size();i++){
        L-=vc[i];
        if(L<0) break; 
        ans++;
    }
    cout << ans;
    return 0;
}
0