记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 2ms 204.0 KiB
#2 Accepted 1ms 232.0 KiB
#3 Accepted 1ms 216.0 KiB
#4 Accepted 1ms 224.0 KiB
#5 Accepted 1ms 220.0 KiB
#6 Accepted 1ms 232.0 KiB
#7 Accepted 1ms 220.0 KiB
#8 Accepted 1ms 228.0 KiB
#9 Accepted 1ms 220.0 KiB
#10 Accepted 1ms 228.0 KiB
#11 Accepted 0ms 220.0 KiB
#12 Accepted 0ms 128.0 KiB
#13 Accepted 0ms 216.0 KiB

代码

#include<stdio.h>
#include<stdlib.h>
#define maxn 10005
int m = 0, k = 0;
int dp[maxn];
int f(int i)
{
	if (i > m)
	{
		for (int j = 1; j <= m; j++)
		{
			int flag = 1;
			for (int l = k; l >= 1; l--)
				if (i - j - l < 0 || dp[i - j - l] == 0)
				{
					flag = 0;
					break;
				}
			if (flag)
				return 1;
		}
		return 0;
	}
	else
		return 1;
}

int main()
{
	int n;
	int ai[maxn];
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", &ai[i]);
	int max = ai[0];
	for (int i = 1; i < n; i++)
		if (ai[i] > max) max = ai[i];
	dp[0] = 0;
	for (int i = 1; i <= max; i++)
	{
		dp[i] = f(i);
		//printf(" %d", dp[i]);
	}
	int flag = 1;
	for (int i = 0; i < n; i++)
		if (dp[ai[i]] == 0)
		{
			flag = 0; 
			break;
		}
	if (flag)
		printf("Yes");
	else
		printf("No");

	return 0;
}

信息

递交者
类型
递交
题目
P1002 hitwh 2019 新生赛 C cqsss and his enterprise
语言
C
递交时间
2020-12-24 20:29:45
评测时间
2020-12-24 20:29:45
评测机
分数
100
总耗时
16ms
峰值内存
232.0 KiB