提交记录 16537
提交时间 |
评测时间 |
2021-10-02 18:54:53 |
2021-10-02 18:55:14 |
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
const int bagg = 1000;
const int numm = 100005;
using namespace std;
int t, n;
int now[bagg];
int f[numm];
int ans;
int cup[numm];
void bag() {
// printf("%d",f[now[1]*2]);
for (int i = 1; i <= n; i++) {
if (f[now[i]]) {
ans++;
continue;
}
for (int j = now[i]; j <= now[n]; j++) {
f[j] = f[j - now[i]] | f[j];
}
}
}
int main() {
scanf("%d", &t);
for (int i = 1; i <= t; i++) {
scanf("%d", &n);
ans = 0;
memset(f, 0, sizeof(f));
memset(cup, 0, sizeof(cup));
for (int j = 1; j <= n; j++) {
scanf("%d", &now[j]);
}
f[0]=1;
sort(now + 1, now + 1 + n);
// f[now[1]] = true;
bag();
//if(!ans) printf("%d\n",n);
printf("%d\n", n - ans);
}
return 0;
}
/*20
3
170 962 891
3
162 4 379
3
250 615 750
3
570 46 299
3
415 634 110
3
564 297 987
3
256 396 992
3
424 480 234
3
264 940 380
3
265 165 224
3
640 68 136
3
933 602 427
3
184 736 648
3
894 103 344
3
851 740 370
3
622 28 231
3
822 264 895
3
250 1000 500
3
679 469 938
3
187 564 282
*/
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 415.13 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #2 | 423.53 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #3 | 423.91 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #4 | 419.6 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #5 | 419.97 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #6 | 418.93 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #7 | 420.64 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #8 | 420.61 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #9 | 424.6 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #10 | 426.32 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #11 | 419.57 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #12 | 419.54 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #13 | 420.46 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #14 | 433.56 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #15 | 432.87 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #16 | 431.84 us | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #17 | 5.652 ms | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #18 | 5.692 ms | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #19 | 5.683 ms | 820 KB | Accepted | Score: 5 | 显示更多 |
Testcase #20 | 5.796 ms | 820 KB | Accepted | Score: 5 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:45:59 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠