|
- //
- #include<iostream>
- #include<cstdlib>
- #include<cstdio>
- #include<algorithm>
- #define maxium 100000000
- using namespace std;
- int s,n,d;
- struct node{
- int need,money;
- }bonds[15];
- int m[50];
- int f[maxium];
- void read()
- {
- cin>>s>>n>>d;
- for(int i=1;i<=d;i++)
- cin>>bonds[i].need>>bonds[i].money;
- return;
- }
- void work()
- {
- read();
- m[0]=s;
- for(int i=1;i<=n;i++){
- for(int j=1;j<=d;j++)
- for(int k=bonds[j].need;k<=m[i-1];k++)
- f[k]=max(f[k],f[k-bonds[j].need]+bonds[j].money);
- m[i]=f[m[i-1]]+m[i-1];
- }
- cout<<m[n];
- return;
- }
- int main()
- {
- work();
- return 0;
- }
复制代码 |
|