結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2019-09-07 11:45:32 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 794 bytes |
コンパイル時間 | 993 ms |
コンパイル使用メモリ | 103,236 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 07:16:31 |
合計ジャッジ時間 | 2,215 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#define _USE_NATH_DEFINES #include<cstdio> #include <iostream> #include<sstream> #include<fstream> #include<iomanip> #include<algorithm> #include<cmath> #include<complex> #include <string> #include<vector> #include<list> #include<queue> #include<stack> #include<set> #include<map> #include<bitset> #include<numeric> #include<limits> #include<climits> #include<cfloat> #include<functional> #include<iterator> #include <random> using namespace std; #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; #define EPS 1e-9 int main() { int l, n; cin >> l >> n; vector<int> w(n); rep(i, n) cin >> w[i]; sort(w.begin(), w.end()); int ans = 0; rep(i, n) { l -= w[i]; if (l < 0) break; else { ans++; } } cout << ans << endl; }