Scales S
题目 Scales S
思路分析
一眼看过去 n中选m 求最大值
每种物品有两种选择 选或不选
两种解法——dfs、01背包dp
有点坑的地方是
dfs能60分 dp只能20分(内存、空间超限)
代码实现
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using Pll = pair<ll, ll>;
int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
const int inf = 0x3f3f3f3f;
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
return 0;
}
💬 评论