結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2019-02-21 02:34:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 5,000 ms |
コード長 | 954 bytes |
コンパイル時間 | 1,850 ms |
コンパイル使用メモリ | 198,068 KB |
最終ジャッジ日時 | 2025-01-06 21:18:45 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include "bits/stdc++.h" using namespace std; using ll = long long; using ull = unsigned long long; using vb = vector<bool>; using vvb = vector<vb>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using pii = pair<int,int>; using pll = pair<ll,ll>; #define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i) #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend() #define eb(val) emplace_back(val) const double PI = acos(-1); const double EPS = 1e-10; const ll MOD = 1e9+7; //#define int ll void cioacc(){//accelerate cin/cout cin.tie(0); ios::sync_with_stdio(false); } signed main(){ int l,n; cin >> l >> n; vi a(n); REP(i,n) cin >> a.at(i); sort(ALL(a)); int wt = 0; int ans = 0; REP(i,n){ if(wt+a.at(i)>l) break; wt += a.at(i); ++ans; } cout << ans << endl; }