結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2018-09-24 08:54:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 5,000 ms |
| コード長 | 664 bytes |
| コンパイル時間 | 735 ms |
| コンパイル使用メモリ | 78,244 KB |
| 最終ジャッジ日時 | 2025-01-06 13:44:31 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#define loop while(1)
#define SZ(x) ((int)(x).size())
#define tep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pushb push_back
#define popb pop_back
#define i64 long long int
#define veci vector<int>
#define vveci vector<VI>
#define veci64 vector<i64>
using namespace std;
int main()
{
int l,n;
veci w;
int tmp;
cin>>l>>n;
tep(i,n){
cin>>tmp;
w.pushb(tmp);
}
sort(w.begin(),w.end());
int score =0;
int num=0;
while(score<=l && num <w.size()){
score+=w[num];
if(score<=l){
num++;
}
}
cout<<num<<endl;
return 0;
}