提交记录 11288


用户 题目 状态 得分 用时 内存 语言 代码长度
Qingyu noip18b. 【NOIP2018】货币系统 Accepted 100 1.649 ms 56 KB C++11 848 B
提交时间 评测时间
2019-11-13 15:23:46 2020-08-01 02:41:32
#include <bits/stdc++.h>

constexpr int N = 100 + 5;

int a[N];
std::bitset<25005> f;

inline char nc()
{
	static char buf[1000000], *p1 = buf, *p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;
}

inline int read()
{
	int res = 0;
	char ch;
	do ch = nc(); while (ch < 48 or ch > 57);
	do res = res * 10 + ch - 48, ch = nc(); while (ch >= 48 && ch <= 57);
	return res;
}

int main()
{
	int T = read();
	while (T--)
	{
		int n = read(), ans = n;
		for (int i = 0; i < n; ++i) a[i] = read();
		std::sort(a, a + n);
		f.reset();
		f[0] = 1;
		for (int i = 0; i < n; ++i)
		{
			if (f[a[i]]) --ans;
			else
			{
				int bound = a[n - 1] / a[i];
				for (int j = 1; j <= bound; bound -= j, j <<= 1) f |= f << (j * a[i]);
				f |= f << (bound * a[i]);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1105.35 us48 KBAcceptedScore: 5

Testcase #288.91 us48 KBAcceptedScore: 5

Testcase #388.82 us48 KBAcceptedScore: 5

Testcase #4110.92 us48 KBAcceptedScore: 5

Testcase #5109.9 us48 KBAcceptedScore: 5

Testcase #6107.34 us48 KBAcceptedScore: 5

Testcase #7126.77 us48 KBAcceptedScore: 5

Testcase #8123.37 us48 KBAcceptedScore: 5

Testcase #9144.6 us48 KBAcceptedScore: 5

Testcase #10203.22 us48 KBAcceptedScore: 5

Testcase #11150.75 us48 KBAcceptedScore: 5

Testcase #12144.64 us48 KBAcceptedScore: 5

Testcase #13144.12 us48 KBAcceptedScore: 5

Testcase #14214.57 us48 KBAcceptedScore: 5

Testcase #15249.4 us48 KBAcceptedScore: 5

Testcase #16246.5 us48 KBAcceptedScore: 5

Testcase #171.575 ms56 KBAcceptedScore: 5

Testcase #181.649 ms56 KBAcceptedScore: 5

Testcase #191.634 ms56 KBAcceptedScore: 5

Testcase #201.641 ms56 KBAcceptedScore: 5


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