結果
問題 | No.5 数字のブロック |
ユーザー |
|
提出日時 | 2022-10-04 14:01:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 696 bytes |
コンパイル時間 | 2,145 ms |
コンパイル使用メモリ | 171,464 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 22:23:38 |
合計ジャッジ時間 | 3,141 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include<bits/stdc++.h>using namespace std;#define int long long#define pb emplace_back#define sz(v) (int)(v.size())#define all(v) (v.begin(),v.end())signed main(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);// freopen("input.txt","r",stdin);// freopen("output.txt","w",stdout);int l,n;cin >> l >> n;vector<int> v(n);for(int i = 0;i<n;i++){cin >> v[i];}sort(v.begin(),v.end());int dp[n];dp[0] = v[0];for(int i = 1;i<n;i++){dp[i] = dp[i-1] + v[i];}for(int i = 0;i<n;i++){if(dp[i] > l){cout << i;return 0;}else if(dp[i] == l){cout << i+1;return 0;}}cout << n;return 0;}