結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-18 09:22:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 751 bytes |
| コンパイル時間 | 820 ms |
| コンパイル使用メモリ | 81,976 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 11:55:09 |
| 合計ジャッジ時間 | 17,271 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <unordered_map>
inline int get_how_many(const std::vector<int>& W,std::unordered_map<int,int>& how_many,int L){
if(how_many.end() == how_many.find(L)){
how_many[L] = 0;
for(auto w : W){
if(L - w >= 0){
how_many[L] = std::max(how_many[L],get_how_many(W,how_many,L-w)+1);
}
}
}
return how_many[L];
}
int main(){
int L,N;
std::vector<int> W{};
std::unordered_map<int,int> how_many{};
std::cin >> L >> N;
how_many.reserve(L+1);
W.reserve(N);
std::copy_n(std::istream_iterator<int>(std::cin),N,std::back_inserter(W));
how_many[0] = 0;
std::cout << get_how_many(W,how_many,L) << std::endl;
return 0;
}