Russian Dolls

本文深入探讨了深度学习在人工智能领域的应用,包括神经网络、机器学习算法及其在图像处理、自然语言处理和强化学习等领域的实践案例。
部署运行你感兴趣的模型镜像
Time Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:65536KB
Total submit users: 12, Accepted users: 9
Problem 12895 : No special judgement
Problem description

Maybe you know the famous russian souvenir Russian Dolls. It looks like a set of nested wooden dolls. A doll with a smaller size is placed inside a bigger one. Let's consider all dolls taken apart. Each doll has an outer volume outi which is the volume it occupies in space and an inner volume ini - the volume of the empty space inside the doll. You may assume that you can put one doll inside another if the outer volume of the first doll is strictly less than the inner volume of the second one. If two or more dolls are inside another one they can't lie one near the other, they must be nested.

For each doll the cost of unit of empty space - costi is known. You must pay exactly costi for each unit of empty space which directly belongs to the i-th doll (but not to ones inside it). You may arrange the dolls the way you want as long as you are not contradicting the rules. The objective is to find an arrangement of nesting the dolls (not necessarily all of them) such that the overall cost you have to pay is minimized.


Input

First line contains an integer N (1 ≤ N ≤ 1000) which is the number of dolls you have. The i-th of the next N lines contains three integers outi, ini, costi (1 ≤ ini < outi ≤ 1000, 1 ≤ costi ≤ 1000), which are the outer volume, inner volume and the empty space cost of the i-th doll.


Output

Single integer P which is the minimum possible cost you should pay.


Sample Input
3
5 4 1
4 2 2
3 2 1
Sample Output
7
#include<iostream>
#include<cstring>//一个是思路问题,一个是要是升序问题,一个是排序后它会变序,要新建一个数组排序 
#include<cstdio>
#include<algorithm>//求最大值时别忘了改值 
#define inf 999999
#define maxn 1010
using namespace std;
int outi[maxn];
int ini[maxn];
struct node
{
	int out,in,cos;
}str[maxn];
bool v[maxn]; 
int temp[maxn];
bool cmpa(int a,int b)
{
	return str[a].out>str[b].out;
}
bool cmpb(int a,int b)//这是升序吧 
{
	if(str[a].in==str[b].in)
	return str[a].cos>str[b].cos;
	return str[a].in>str[b].in;
}
int main()//break,初始化 
{
	int T;
	while(scanf("%d",&T)!=EOF)
	{
		for(int i=1;i<=T;i++)
		{
			cin>>str[i].out>>str[i].in>>str[i].cos;
			ini[i]=i;outi[i]=i;
		}
		sort(outi+1,outi+T+1,cmpa);//排序问题,升序 
		sort(ini+1,ini+T+1,cmpb);
		int ans=0;
		memset(v,0,sizeof(v));
		for(int i=1;i<=T;i++)
		{
			int x=0;
			for(int j=1;j<=T;j++)
			{
				if(str[outi[i]].out<str[ini[j]].in&&!v[ini[j]])
			 
				temp[++x]=ini[j];
			}
			//cout<<x<<endl;
			if(x>=1)
			{
			
			int vmax=0;
			int res;
			for(int k=1;k<=x;k++)
			{
			
				int tep=str[temp[k]].cos*str[outi[i]].out;//减的量 
				//cout<<tep<<endl;
				if(vmax<tep)
				{
					vmax=tep;
					res=temp[k];//这里一开始忘了改值 
				}
			}
			v[res]=1;
			//cout<<res<<endl;
			ans+=str[res].cos*str[outi[i]].out;
		    }
		}
		int result=0;
		for(int i=1;i<=T;i++)
		{
			result+=str[i].cos*str[i].in;
		}
		
		result-=ans;
		//cout<<ans<<endl;
		cout<<result<<endl;
	}
}

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

内容概要:本文围绕“基于数据驱动的 Koopman 算子的递归神经网络模型线性化,用于纳米定位系统的预测控制研究”展开,提出了一种结合Koopman算子理论与递归神经网络(RNN)的数据驱动建模方法,旨在对非线性纳米定位系统进行有效线性化建模,并实现高精度的模型预测控制(MPC)。该方法利用Koopman算子将非线性系统映射到高维线性空间,通过递归神经网络学习系统的动态演化规律,构建可解释性强、计算效率高的线性化模型,进而提升预测控制在复杂不确定性环境下的鲁棒性与跟踪精度。文中给出了完整的Matlab代码实现,涵盖数据预处理、网络训练、模型验证与MPC控制器设计等环节,具有较强的基于数据驱动的 Koopman 算子的递归神经网络模型线性化,用于纳米定位系统的预测控制研究(Matlab代码实现)可复现性和工程应用价值。; 适合人群:具备一定控制理论基础和Matlab编程能力的研究生、科研人员及自动化、精密仪器、机器人等方向的工程技术人员。; 使用场景及目标:①解决高精度纳米定位系统中非线性动态响应带来的控制难题;②实现复杂机电系统的数据驱动建模与预测控制一体化设计;③为非线性系统控制提供一种可替代传统机理建模的有效工具。; 阅读建议:建议结合提供的Matlab代码逐模块分析实现流程,重点关注Koopman观测矩阵构造、RNN网络结构设计与MPC控制器耦合机制,同时可通过替换实际系统数据进行迁移验证,深化对数据驱动控制方法的理解与应用能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值