提交记录 10620


用户 题目 状态 得分 用时 内存 语言 代码长度
Zhouzj2004 noip18b. 【NOIP2018】货币系统 Accepted 100 15.465 ms 40 KB C++ 802 B
提交时间 评测时间
2019-09-21 17:01:39 2020-08-01 02:18:22
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100
#define MAX 25000

using namespace std;

void read(int &x)
{
	char ch=getchar(); x=0;
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=x*10+ch-48,ch=getchar();
}

int a[N+1],n,T;
bool bz[MAX+1];

void qsort(int l,int r)
{
	int i=l,j=r,mid=a[l+r>>1];
	while (i<=j)
	{
		while (a[i]<mid) ++i;
		while (a[j]>mid) --j;
		if (i<=j) swap(a[i++],a[j--]);
	}
	if (i<r) qsort(i,r);
	if (j>l) qsort(l,j);
}

int main()
{
	for (read(T);T-->0;)
	{
		read(n);
		for (int i=1;i<=n;i++) read(a[i]);
		qsort(1,n);
		memset(bz,0,sizeof bz); bz[0]=1;
		int ans=0;
		for (int i=1;i<=n;i++)
		{
			if (! bz[a[i]]){
				++ans;
				for (int j=a[i];j<=a[n];j++) 
					bz[j]=bz[j]||bz[j-a[i]];
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #123.72 us40 KBAcceptedScore: 5

Testcase #227.35 us40 KBAcceptedScore: 5

Testcase #327.67 us40 KBAcceptedScore: 5

Testcase #426.89 us40 KBAcceptedScore: 5

Testcase #525.74 us40 KBAcceptedScore: 5

Testcase #626.79 us40 KBAcceptedScore: 5

Testcase #732.23 us40 KBAcceptedScore: 5

Testcase #831.73 us40 KBAcceptedScore: 5

Testcase #936.74 us40 KBAcceptedScore: 5

Testcase #1040.75 us40 KBAcceptedScore: 5

Testcase #1129.7 us40 KBAcceptedScore: 5

Testcase #1229.97 us40 KBAcceptedScore: 5

Testcase #1328.49 us40 KBAcceptedScore: 5

Testcase #1444.32 us40 KBAcceptedScore: 5

Testcase #1545.06 us40 KBAcceptedScore: 5

Testcase #1640.06 us40 KBAcceptedScore: 5

Testcase #1714.199 ms40 KBAcceptedScore: 5

Testcase #1815.391 ms40 KBAcceptedScore: 5

Testcase #1915.465 ms40 KBAcceptedScore: 5

Testcase #2015.254 ms40 KBAcceptedScore: 5


Judge Duck Online | 评测鸭在线
Server Time: 2024-03-29 02:40:07 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用