提交记录 16537


用户 题目 状态 得分 用时 内存 语言 代码长度
orposter noip18b. 【NOIP2018】货币系统 Accepted 100 5.796 ms 820 KB C++ 1.05 KB
提交时间 评测时间
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
*/

CompilationN/AN/ACompile OKScore: N/A

Testcase #1415.13 us820 KBAcceptedScore: 5

Testcase #2423.53 us820 KBAcceptedScore: 5

Testcase #3423.91 us820 KBAcceptedScore: 5

Testcase #4419.6 us820 KBAcceptedScore: 5

Testcase #5419.97 us820 KBAcceptedScore: 5

Testcase #6418.93 us820 KBAcceptedScore: 5

Testcase #7420.64 us820 KBAcceptedScore: 5

Testcase #8420.61 us820 KBAcceptedScore: 5

Testcase #9424.6 us820 KBAcceptedScore: 5

Testcase #10426.32 us820 KBAcceptedScore: 5

Testcase #11419.57 us820 KBAcceptedScore: 5

Testcase #12419.54 us820 KBAcceptedScore: 5

Testcase #13420.46 us820 KBAcceptedScore: 5

Testcase #14433.56 us820 KBAcceptedScore: 5

Testcase #15432.87 us820 KBAcceptedScore: 5

Testcase #16431.84 us820 KBAcceptedScore: 5

Testcase #175.652 ms820 KBAcceptedScore: 5

Testcase #185.692 ms820 KBAcceptedScore: 5

Testcase #195.683 ms820 KBAcceptedScore: 5

Testcase #205.796 ms820 KBAcceptedScore: 5


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:45:59 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠