Yuyuko and Youmu

Yuyuko and Youmu

Time Limit: 10 Seconds       Memory Limit: 65536 KB

Saigyouji Yuyuko (西行寺幽々子), the ghost from the calamitous nirvana, is the princess of Hakugyokurou (白玉楼) in the Netherworld, while Konpaku Youmu (魂魄妖夢), half-human half-phantom, is the gardener of Hakugyokurou. Yuyuko is famous as a "hungry ghost" having an immense appetite. So Youmu is alway busy preparing enough food for her.

For the coming n days, knowing the amount of food Yuyuko needs and the amount of food Youmu can prepare at each day, Youmu wants to make an arrangement so that Yuyuko can eat enough food everyday, and the food is as fresh as possible. There are no food remained in Hakugyokurou currently.

Input

There are multiple cases. The first line of each case contains a integer n (1 ≤ n ≤ 1000). The second line contains n integers (1 ≤ ai ≤ 1000000), the amount of food Yuyuko needs at each day. The third line contains n integers (1 ≤ bi ≤ 1000000), the amount of food Youmu can prepare at each day.

Output

If an arrangement exists, output n integers, the amount of food Youmu should prepare at each day. If not, output a line of "Myon".

Sample Input
5
10 10 100 10 10
50 50 50 50 50
9
1 2 4 8 16 32 64 128 256
10 10 10 10 10 10 10 10 10
Sample Output
20 50 50 10 10
Myon
 
题意:这个人每天要吃一定数量的食物,但是他每天也能采集一定数量的食物,但是他又想吃最新鲜的食物(其实就是最小值),问他每天要采集多少食物才不会被饿死。
题目比较水,稍加分析就行。
分析:从最后一天倒着往前走。第n天要采集的量是第n天要吃的量加上前一天没采集够的量。如果要采集的量小于这一天能采集的最大量,那么剩余的那部分就是0,否则向前累加。最后检查第一天要采集的量和他能采集的最大量就行。
#include<iostream>
#include<string>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
	int n,i,k,sum;
	int a[1010],b[1010],c[1010];
	int max;
	while(~scanf("%d",&n))
	{
		sum=0;
		memset(c,0,sizeof(c));
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			if(max<a[i])
			{
				k=i;
				max=a[i];
			}
		}
		for(i=0;i<n;i++)
		{
			scanf("%d",&b[i]);
		}
		for(i=n-1;i>0;i--)
		{
			if(a[i]+sum<b[i])//就是这里是代码的核心。
			{
				c[i]=a[i]+sum;
				sum=0;
			}
			else
			{
				sum=a[i]-b[i]+sum;
				c[i]=b[i];
			}
		}
		if(a[0]+sum>b[0])
		{
			cout<<"Myon"<<endl;
		}
		else
		{
			c[0]=a[i]+sum;
			for(i=0;i<n;i++)
			{
				if(i<n-1)
				cout<<c[i]<<" ";
				else
				{
					cout<<c[i]<<endl;
				}
			}
		
		}
		
	}
}


【资源介绍】 1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,也可以作为小白实战演练和初期项目立项演示的重要参考借鉴资料。 3、本资源作为“学习资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研和多多调试实践。 图像数据处理工具+数据(帮助用户快速划分数据集并增强图像数据集。通过自动化数据处理流程,简化了深度学习项目的数据准备工作).zip 图像数据处理工具+数据(帮助用户快速划分数据集并增强图像数据集。通过自动化数据处理流程,简化了深度学习项目的数据准备工作).zip 图像数据处理工具+数据(帮助用户快速划分数据集并增强图像数据集。通过自动化数据处理流程,简化了深度学习项目的数据准备工作).zip 图像数据处理工具+数据(帮助用户快速划分数据集并增强图像数据集。通过自动化数据处理流程,简化了深度学习项目的数据准备工作).zip 图像数据处理工具+数据(帮助用户快速划分数据集并增强图像数据集。通过自动化数据处理流程,简化了深度学习项目的数据准备工作).zip 图像数据处理工具+数据(帮助用户快速划分数据集并增强图像数据集。通过自动化数据处理流程,简化了深度学习项目的数据准备工作).zip 图像数据处理工具+数据(帮助用户快速划分数据集并增强图像数据集。通过自动化数据处理流程,简化了深度学习项目的数据准备工作).zip 图像数据处理工具+数据(帮助用户快速划分数据集并增强图像数据集。通过自动化数据处理流程,简化了深度学习项目的数据准备工作).zip
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值