#include<iostream> #include<algorithm> #include<cmath> #include<cstring> #include<vector> #include<queue> #include<unordered_map> #include<map> #include<set> #include<unordered_set> #define fi first #define se second #define VI vector<int> #define VS vector<string> #define sortq(q) sort(q.begin(),q.end()) #define IOS ios::sync_with_stdio(false),cin.tie(nullptr) #define endl '\n' #define PII pair<int ,int> #define PIS pair<int ,string> #define PSI pair<string ,int> #define PSS pair<string ,string> // #define int long long #define mod 1000000010
usingnamespace std; inlineintread(){ int x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();} return x*f; } string& replace(int pos, int n, constchar *s);//将当前字符串从pos索引开始的n个字符,替换成字符串s string& replace(int pos, int n, int n1, char c); //将当前字符串从pos索引开始的n个字符,替换成n1个字符c // s1.replace(s1.size()-1,1,1,'.'); // 结果:hello,world. constint N = 1010; int n,m; int f[N][N]; //动态规划第一点:递推关系式 //动态规划第二点:怎么初始化 //f[i][j]表示是看前i个物品,总体积是j的情况下,总价值最大是多少 //result = max(f[n][0~V]) int v[N],w[N];
#include<iostream> #include<algorithm> #include<cmath> #include<cstring> #include<vector> #include<queue> #include<unordered_map> #include<map> #include<set> #include<unordered_set> #define fi first #define se second #define VI vector<int> #define VS vector<string> #define sortq(q) sort(q.begin(),q.end()) #define IOS ios::sync_with_stdio(false),cin.tie(nullptr) #define endl '\n' #define PII pair<int ,int> #define PIS pair<int ,string> #define PSI pair<string ,int> #define PSS pair<string ,string> #define int long long #define mod 1000000010
usingnamespace std; inlineintread(){ int x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();} return x*f; } string& replace(int pos, int n, constchar *s);//将当前字符串从pos索引开始的n个字符,替换成字符串s string& replace(int pos, int n, int n1, char c); //将当前字符串从pos索引开始的n个字符,替换成n1个字符c // s1.replace(s1.size()-1,1,1,'.'); // 结果:hello,world. constint N = 1010; int n,m;/////闫式DP分析法,得再纸上自己推一遍 int f[N][N]; int w[N],v[N];