数据有误
查看原帖
数据有误
263469
Ink_Bottle楼主2020/5/24 19:49

大家看一下,这份代码得到的是50分:

#include<bits/stdc++.h>

using namespace std;
int n,m,k,a,t;
int dp[1000001];
int main()
{
	//freopen("watch.in","r",stdin);
	//freopen("watch.out","w",stdout);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		cin >> a >> k;
		k=min(k,500000/a);
		for(int i=1;i<=k;i++)
		  for(int j=500000;j>=a;j--)
		  dp[j]=dp[j]||dp[j-a];
	}
	for(int i=1;i<=m;i++)
	{
		cin >> t;
		//if(t>250) cout << "hahahaha" << endl; 
		if(dp[t]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

记录1

而加上特判后:

#include<bits/stdc++.h>

using namespace std;
int n,m,k,a,t;
int dp[1000001];
int main()
{
	//freopen("watch.in","r",stdin);
	//freopen("watch.out","w",stdout);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		cin >> a >> k;
		k=min(k,500000/a);
		for(int i=1;i<=k;i++)
		  for(int j=500000;j>=a;j--)
		  dp[j]=dp[j]||dp[j-a];
	}
	for(int i=1;i<=m;i++)
	{
		cin >> t;
		if(t>250) cout << "hahahaha" << endl;//唯一的区别 
		if(dp[t]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

只有30分

记录2

强烈谴责出题人用脚造数据

2020/5/24 19:49
加载中...