結果

問題 No.5 数字のブロック
ユーザー mell1
提出日時 2019-03-28 14:45:54
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 319 bytes
コンパイル時間 1,691 ms
コンパイル使用メモリ 163,416 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-18 13:06:10
合計ジャッジ時間 2,785 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,sum=0,i;
    cin>>n>>m;
    
    vector<int> a(m);
    
    for(int j=0;j<m;j++){
        cin>>a.at(j);
    }
    
    sort(a.begin(),a.end());
    
    for(i=0;i<m;i++){
        sum+=a.at(i);
        if(sum>n) break;
    }
    
    cout<<i<<"\n";
}
0