RoboCom-CAIP 2021 本科组复赛

https://pintia.cn/problem-sets/1449304600741462016/problems/1449304670132027392


7-1 冒险者分队

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N=1e5+5;
ll w[5];
ll solve(){
	ll a,b,c,ta,tb,tc;cin>>a>>b>>c>>ta>>tb>>tc;
	w[0]=a-ta;w[1]=b-tb;w[2]=c-tc;
	if(w[0]+w[1]+w[2]!=0) return -1;
	if(w[0]%20!=0||w[1]%20!=0||w[2]%20!=0) return -1;
	w[0]/=20;w[1]/=20;w[2]/=20;
	int mod=(w[0]%3+3)%3;
	for(int i=0;i<3;i++)
		if((w[i]%3+3)%3!=mod) return -1;
    int f=0;
	for(int i=0;i<3;i++) if(w[i]>0) f++;
	if(f>1) for(int i=0;i<3;i++) w[i]=-w[i];
	// - - + 的形式 
	sort(w,w+3);
	int cnt=0;
	cnt+=-w[1];
	w[2]-=cnt*2; 
	//+2 -1 -1 和 +1 +1 -2
	//组合出 +3 0 +3 
	cnt+=w[2]/3*2;
	return cnt;
}
int main(){
	
	int t;cin>>t;
	while(t--){
		ll res=solve();
		cout<<((res==-1)?-1:res)<<endl;
	}
	
} 

7-2 拼题A打卡奖励

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N=1e3+5,M=3e4;
int n,m;
int w[N],v[N];
int f[M+5];
int res;
int main(){
	cin>>n>>m;
	memset(f,0x3f,sizeof f);
	f[0]=0;
	for(int i=1;i<=n;i++) cin>>w[i];//时间 
	for(int i=1;i<=n;i++) cin>>v[i];//奖励 
	for(int i=1;i<=n;i++)
		for(int j=M;j>=v[i];j--)
			f[j]=min(f[j],f[j-v[i]]+w[i]);
	for(int i=0;i<=M;i++)
		if(f[i]<=m) res=i;
	cout<<res;
} 

后面不会了。。随缘补吧

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Vic.GoodLuck

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

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

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

打赏作者

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

抵扣说明:

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

余额充值