結果

問題 No.5 数字のブロック
ユーザー 👑 Nachia
提出日時 2020-09-27 11:40:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 359 bytes
コンパイル時間 1,775 ms
コンパイル使用メモリ 169,884 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 11:51:33
合計ジャッジ時間 2,809 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int L, N;
int W[10000];

int main() {
    cin >> L >> N;
    rep(i, N) cin >> W[i];
    sort(W, W + N);
    int ans = 0;
    rep(i, N) { if (L >= W[i]) { L -= W[i]; ans++; } }
    cout << ans << endl;

    return 0;
}
0