您当前的位置: 首页 > 

*DDL_GzmBlog

暂无认证

  • 5浏览

    0关注

    605博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

[luogu] P4138 [JOISC2014] 挂饰 01背包DP+贪心

*DDL_GzmBlog 发布时间:2021-11-07 16:13:48 ,浏览量:5

前言

事实告诉我们 不要乱定义变量

传送门 :

思路 CODE
// Problem: P4138 [JOISC2014] 挂饰
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P4138
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

// Problem: P2738 [USACO4.1]���ʻ�·Fence Loops
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P2738
// Memory Limit: 125 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include 
using namespace std;
#define ll long long
#define endl '\n'
#define px first
#define py second
#define pb push_back
typedef pair pii;
int dxy[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
const int N  = 2e3+10,INF = 0x3f3f3f3f;


struct union_find_set{
    int n,p[N];

    void init(int N)
    {
        n = N;
        for(int i=1;ib;
	
}
int s[N];

void solve()
{
	cin>>n;
	pl_sum =  1;
	
	for(int i=1;i>a[i]>>b[i];
		
		
		if(a[i] == 0 )
		{
			if(b[i]=0)
			{
				pl_sum+=(a[i]-1);
				pl_ans+=b[i];
			}//必拿
			else
			{
				++node_idx;
				p[node_idx] = {a[i]-1,b[i]};
			}
		}
	}
	pl_sum = min(pl_sum,n);
	//总共就n个物品 
	
	for(int i = 0 ;i            
关注
打赏
1657615554
查看更多评论
0.0535s