数组欠大
by Loser_King @ 2020-07-09 15:54:24
你那个数组开得太大了
by TKater_yzt @ 2020-07-09 16:00:59
@[MuoDq336](/user/307826) 数组太大了,二维数组大小不能开到100000,顶多10000,要不然会像我一样——
1=变2=
(心碎)
by 出言不逊王子 @ 2020-07-09 16:01:05
```cpp
int f[100000][100000],
```
10^5*10^5=10^10
这个内存肯定要爆的
by TKater_yzt @ 2020-07-09 16:02:06
@[出言不逊王子](/user/336603) ~~`bitset bool`数组100000没问题呀~~
by liqingyang @ 2020-07-09 16:07:46
@[liqingyang](/user/272088) 我说的是二维bool数组+您怎么知道我用的是bool而不是char?
by 出言不逊王子 @ 2020-07-09 16:12:29
lz貌似已经AC了此题
by WanderingTrader @ 2020-07-09 16:43:20
```cpp
#include<iostream>
using namespace std;
int n,m;
int w[35],v[35];
int opt[205];
int main()
{
cin>>m>>n;
for(int i=1;i<=n;i++)
cin>>w[i]>>v[i];
for(int i=1;i<=n;i++)
for(int j=m;j>=w[i];j--)
opt[j]=max(opt[j],opt[j-w[i]]+v[i]);
cout<<opt[m]<<endl;
return 0;
}
```
by 头狸 @ 2020-08-02 18:34:13
```
#include<bits/stdc++.h>
using namespace std;
int t1,m,t[1001],c[1001],f[1001];
int main()
{
cin>>t1>>m;
for(int i=1;i<=m;++i)
cin>>t[i]>>c[i];
for(int i=1;i<=m;++i)
for(int j=t1;j>=t[i];--j)
f[j]=max(f[j],f[j-t[i]]+c[i]);
cout<<f[t1];
return 0;
}
```
by zzy20080701 @ 2020-08-22 11:54:18