⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inflate.cpp

📁 背包类问题浅析和一些背包类问题的解答源程序。
💻 CPP
字号:
/*
ID:zhjshar1
PROG:inflate
LANG:C++
*/
#include <fstream>
using namespace std;

ifstream  in( "inflate.in" );
ofstream out( "inflate.out" );

int main(){
    const int MAXN = 10010;
    int money, totobj, f[MAXN]={0}, value, price, i, j, tem;
    in >>money >>totobj;
    for( i=0; i<totobj; ++i ){
         in >>value >>price;
         for( j=price; j<=money; ++j )
              if( (tem=f[j-price]+value) > f[j] ) f[j] = tem;
    }
    out <<f[money] <<endl;
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -