結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2023-04-01 18:13:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 1,844 bytes |
| コンパイル時間 | 1,717 ms |
| コンパイル使用メモリ | 168,764 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 11:09:53 |
| 合計ジャッジ時間 | 2,862 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
#define ll long long
#define Mod 998244353
#define Mod1 10000000000037
#define ls node[x].lch
#define rs node[x].rch
#define inf 0x7fffffff
#define inf1 1000000009
#define ull unsigned long long
#define llinf 0x7fffffffffffffff
#define llinf1 1000000000000000009
#define IOS ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F(a,b,c,d) for(int b=c;b<=d;b+=a)
#define F2(a,b,c,d) for(int b=c;b>=d;b-=a)
#define PRC(b,a) fixed<<setprecision(a)<<b
using namespace std;
using namespace __gnu_cxx;
template <typename T> inline void read(T &xx){
char cc=getchar();T ff=1; xx=0;
while(cc>'9'||cc<'0'){ ff=cc=='-'?-1:ff,cc=getchar();}
while(cc<='9'&&cc>='0'){ xx=(xx<<1)+(xx<<3)+(cc^48),cc=getchar();}
xx=xx*ff;
}
template <typename T> inline void write(T xx){
if(xx<0){ putchar('-'),xx=-xx;}
if(xx>9) write(xx/10);
putchar(xx%10+'0');
}
inline ll lowbit(ll xx){return xx&(-xx);}
inline ll Gcd(ll xx,ll yy){return yy?Gcd(yy,xx%yy):xx;}
inline ll q_Mul(ll xx,ll yy,ll pp){ll oo=0;while(yy){if(yy&1)oo=(oo+xx)%pp;xx=(xx<<1)%pp;yy>>=1;}return oo;}
inline ll q_Pow(ll xx,ll yy,ll pp){ll oo=1;for(;yy;yy>>=1,xx=xx*xx%pp)yy&1?oo=oo*xx%pp:0;return oo;}
//q_Pow can conbine with q_Mul to avoid overflow
template <typename T> inline T Min(T xx,T yy){return xx<yy?xx:yy;}
template <typename T> inline T Max(T xx,T yy){return xx>yy?xx:yy;}//(XX-YY>>63)?.:.;
template <typename T1,typename...T2>
inline void read(T1 &x,T2& ...y){read(x);read(y...);}
#define All(x) x.begin(),x.end()
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int d2x[8]={1,0,-1,0,1,-1,-1,1},d2y[8]={0,1,0,-1,1,1,-1,-1};
int n,l,a[10010];
signed main(){
//freopen();
//freopen();
IOS
cin>>l>>n;
for(int i=1;i<=n;++i)
cin>>a[i];
sort(a+1,a+1+n);
int i=1;
while(l>=a[i]&&i<=n)
l-=a[i++];
cout<<i-1<<'\n';
return 0;
}