結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
cumin
|
| 提出日時 | 2020-02-28 22:28:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 427 bytes |
| コンパイル時間 | 1,670 ms |
| コンパイル使用メモリ | 170,684 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 17:56:25 |
| 合計ジャッジ時間 | 2,513 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const double pi=acos(-1);
int main(){
int l,n;
cin >> l >> n;
ll sum=0;
int ans=0;
vector<int>w(n);
rep(i,n)cin>>w[i];
sort(w.begin(),w.end());
rep(i,n){
if(sum+w[i]<=l){
sum+=w[i];
ans++;
}
}
cout << ans << endl;
return 0;
}
cumin