結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-10 15:41:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 536 bytes |
| コンパイル時間 | 681 ms |
| コンパイル使用メモリ | 65,600 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 21:26:12 |
| 合計ジャッジ時間 | 1,667 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 14 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class hako
{
public :
int solv(int w, vector<int> array){
int ans=0,sum=0,i=0;
while(sum<w){
sum += array[i];
i++;
}
return i-1 ; //0からはじまっれいるのでarrayの1多いがこれでよい
}
};
int main() {
int n,w;
vector<int> array;
hako hk;
cin>>w;
cin>>n;
for(int i=0; i<n; i++){
int num;
cin>>num;
array.push_back(num);
}
sort(array.begin(),array.end());
cout<<hk.solv(w,array)<<endl;
return 0;
}