結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
mdk_51
|
| 提出日時 | 2019-08-27 17:48:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,219 bytes |
| コンパイル時間 | 4,364 ms |
| コンパイル使用メモリ | 163,876 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-16 08:43:49 |
| 合計ジャッジ時間 | 4,447 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort(all(v))
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int l, n;
cin >> l >> n;
int w[n];
rep(i, n) cin >> w[i];
sort(w, w + n);
rep(i, n) {
l -= w[i];
if(l < 0) {
cout << i << endl;
return 0;
}
}
cout << n << endl;
return 0;
}
mdk_51