結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2017-06-28 23:16:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 636 bytes |
コンパイル時間 | 2,916 ms |
コンパイル使用メモリ | 162,880 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 11:20:47 |
合計ジャッジ時間 | 2,775 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i) #define rep(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define REV(v) v.rbegin(), v.rend() #define MEMSET(v, s) memset(v, s, sizeof(v)) #define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end()) #define MP make_pair #define MT make_tuple int main(){ int L, N, t; vector<int> w; cin >> L; cin >> N; rep(i, N) { cin >> t; w.push_back(t); } sort(ALL(w)); int cnt = 0; for(int a: w) { L -= a; if(L >= 0){ cnt += 1; } else { break; } } cout << cnt << endl; return 0; }