站外题求助,玄棺
查看原帖
站外题求助,玄棺
1059234
FamousKillerconan楼主2024/10/24 19:24

本蒟蒻动规不精,打了个暴搜

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using PII=pair<int,int>;
const int INF=0x3f3f3f3f;
const int N=55;
ll k,n,r[N],g[N],ans=INT_MAX;
ll pw(ll d){
	return d*d*d*d;
}
void dfs(ll dep,ll red,ll green){
	ll cost=pw(red)+green;
	if(cost>=ans)return;
	if(dep>n){
		ans=min(ans,cost);
		return;
	}
	dfs(dep+1,r[dep]+red,green);
	dfs(dep+1,red,green+g[dep]);
}
int main(){
	FAST;
	cin>>k>>n;
	for(int i=1;i<=n;i++)cin>>r[i]>>g[i];
	dfs(1,0,0);
	cout<<ans;
	return 0;
}
2024/10/24 19:24
加载中...