結果

問題 No.5 数字のブロック
ユーザー troro_kelptroro_kelp
提出日時 2018-08-03 13:55:37
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 659 bytes
コンパイル時間 851 ms
コンパイル使用メモリ 74,584 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-18 12:33:11
合計ジャッジ時間 1,725 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
typedef std::pair<std::string,double> P;

int L, N; 
vector<int> v;
int dist[10001];
void solve(){
    for(int i=0; i<N; ++i){
        int a; cin >> a; v.push_back(a);
    }
    sort(v.begin(), v.end());
    int cnt=0, sum=0;
    for(int i=0; i<N; ++i){
        if(sum+v[i]>L) break;
        sum+=v[i]; cnt++;
    }
    cout << cnt << endl;
}
int main() {
    cin >> L >> N;
    solve();
	return 0;
}
0