結果
| 問題 |
No.37 遊園地のアトラクション
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-03-03 01:34:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 702 bytes |
| コンパイル時間 | 345 ms |
| コンパイル使用メモリ | 51,448 KB |
| 最終ジャッジ日時 | 2024-11-14 19:00:40 |
| 合計ジャッジ時間 | 1,003 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:7:24: error: ‘vector’ has not been declared
7 | int func(int t, int k, vector<int>& v, vector<int>& c)
| ^~~~~~
main.cpp:7:30: error: expected ‘,’ or ‘...’ before ‘<’ token
7 | int func(int t, int k, vector<int>& v, vector<int>& c)
| ^
main.cpp: In function ‘int func(int, int, int)’:
main.cpp:12:19: error: ‘v’ was not declared in this scope
12 | for(int i=k;i<v.size();++i) if (t>=c[i])
| ^
main.cpp:12:40: error: ‘c’ was not declared in this scope
12 | for(int i=k;i<v.size();++i) if (t>=c[i])
| ^
main.cpp: In function ‘int main()’:
main.cpp:21:9: error: ‘vector’ was not declared in this scope
21 | vector<int> c(n), v(n);
| ^~~~~~
main.cpp:4:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
3 | #include <cstring>
+++ |+#include <vector>
4 | using namespace std;
main.cpp:21:16: error: expected primary-expression before ‘int’
21 | vector<int> c(n), v(n);
| ^~~
main.cpp:22:21: error: ‘c’ was not declared in this scope
22 | for(int& x: c) cin>>x;
| ^
main.cpp:23:21: error: ‘v’ was not declared in this scope
23 | for(int& x: v) cin>>x;
| ^
main.cpp:25:19: error: ‘v’ was not declared in this scope
25 | int x=v[i], y=c[i];
| ^
main.cpp:26:44: error: ‘c’ was not declared in this scope
26 | while (x/=2) { v.push_back(x); c.push_back(y); }
| ^
main.cpp:26:56: error: ‘y’ was not declared in this scope
26 | while (x/=2) { v.push_back(x); c.push_back(y); }
| ^
main.cpp:29:26: error: ‘v’
ソースコード
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int memo[10010][500];
int func(int t, int k, vector<int>& v, vector<int>& c)
{
int& res=memo[t][k];
if (res) return res;
res=0;
for(int i=k;i<v.size();++i) if (t>=c[i])
res=max(res, func(t-c[i], i+1, v, c)+v[i]);
return res;
}
int main()
{
int t, n;
while (cin>>t>>n) {
vector<int> c(n), v(n);
for(int& x: c) cin>>x;
for(int& x: v) cin>>x;
for(int i=0;i<n;++i) {
int x=v[i], y=c[i];
while (x/=2) { v.push_back(x); c.push_back(y); }
}
memset(memo, 0, sizeof(memo));
cout<<func(t, 0, v, c)<<endl;
}
}
hogeover30