Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
145415 | 冼俊烨 | 货币系统 | C++ | 通过 | 100 | 12 MS | 1248 KB | 778 | 2024-05-05 08:07:33 |
#include <iostream> #include <algorithm> #include <cstring> using namespace std; #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); const int MAX = 1e6 + 7; int info[MAX]; bool dp[MAX]; int main() { IOS; int T; cin >> T; while (T--) { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> info[i]; sort(info + 1, info + 1 + n); memset(dp, 0, sizeof dp); dp[0] = 1; int ans = n; for (int i = 1; i <= n; i++) { if (dp[info[i]]) { ans--; continue; } for (int j = info[i]; j <= info[n]; j++) dp[j] |= dp[j - info[i]]; } cout << ans << endl; } return 0; } //D