2021 RoboCom 世界机器人开发者大赛-本科组(复赛)

在这里插入图片描述


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn=1100;

ll n,m,w[maxn],c[maxn],sumc=0;
ll dp[365*25*60];

int main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld",&w[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&c[i]),sumc+=c[i];
	//dp[i]表示获得i价值使用的最小容量
	memset(dp,0x3f,sizeof dp);
	dp[0]=0; 
	for(int i=1;i<=n;i++){
		for(int j=sumc;j>=c[i];j--){
			dp[j]=min(dp[j],dp[j-c[i]]+w[i]);
		}
	}
	for(int i=sumc;i>=0;i--){
		if(dp[i]<=m){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn=1100;

ll a[4];

int main(){
	int _;scanf("%d",&_);
	while(_--){
		ll x1,y1,z1,x2,y2,z2;
		scanf("%lld%lld%lld",&x1,&y1,&z1);
		scanf("%lld%lld%lld",&x2,&y2,&z2);
		ll x=x1-x2,y=y1-y2,z=z1-z2;
		if(x%20||y%20||z%20){
			puts("-1");continue;
		}
		x=x/20,y=y/20,z=z/20;
		ll tx=(x%3+3)%3,ty=(y%3+3)%3,tz=(z%3+3)%3;
		if(tx!=ty||tx!=tz){
			puts("-1");continue;
		}
		if((x+y+z)!=0){
			puts("-1");continue;
		}
		a[1]=x,a[2]=y,a[3]=z;
		int num=0;
		if(x>0) num++;
		if(y>0) num++;
		if(z>0) num++;
		if(num==2) a[1]*=(-1),a[2]*=(-1),a[3]*=(-1);
		sort(a+1,a+1+3);
		ll ans=0;
	//	cout<<a[1]<<" "<<a[2]<<" "<<a[3]<<endl;
		ans=ans+-1*(a[2]);
		a[3]-=2*ans;
		ans=ans+abs(a[3])/3*2;
		printf("%lld\n",ans);
		//cout<<ans<<endl;
	}
	return 0;
}
/*#-2 1 1
4
25 30 35
65 10 15


100 200 300
200 180 220

100 100 100
0 0 0

777 888 999
777 888 999
##ans=
1
3
-1
0
*/


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

豆沙睡不醒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值