日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > > 充電吧
[導(dǎo)讀]【CF簡介】提交鏈接:CF 514D題面:D. R2D2 and Droid Army time limit per test 2 seconds memory limit per test 25

【CF簡介】

提交鏈接:CF 514D


題面:


D. R2D2 and Droid Army time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output

An army of n droids is lined up in one row. Each droid is described bym integers a1,?a2,?...,?am, whereai is the number of details of thei-th type in this droid's mechanism. R2-D2 wants to destroy the sequence of consecutive droids of maximum length. He hasm weapons, the i-th weapon can affect all the droids in the army by destroying one detail of thei-th type (if the droid doesn't have details of this type, nothing happens to it).

A droid is considered to be destroyed when all of its details are destroyed. R2-D2 can make at mostk shots. How many shots from the weapon of what type should R2-D2 make to destroy the sequence of consecutive droids of maximum length?

Input

The first line contains three integers n,?m,?k (1?≤?n?≤?105, 1?≤?m?≤?5, 0?≤?k?≤?109) — the number of droids, the number of detail types and the number of available shots, respectively.

Next n lines follow describing the droids. Each line containsm integers a1,?a2,?...,?am (0?≤?ai?≤?108), where ai is the number of details of thei-th type for the respective robot.

Output

Print m space-separated integers, where thei-th number is the number of shots from the weapon of thei-th type that the robot should make to destroy the subsequence of consecutive droids of the maximum length.

If there are multiple optimal solutions, print any of them.

It is not necessary to make exactly k shots, the number of shots can be less.

Examples Input

5?2?4
4?0
1?2
2?1
0?2
1?3

Output

2?2

Input

3?2?4
1?2
1?3
2?2

Output

1?3

Note

In the first test the second, third and fourth droids will be destroyed.

In the second test the first and second droids will be destroyed.



題意:

???? 有n個(gè)有序排列的機(jī)器人,每個(gè)機(jī)器人有m項(xiàng)屬性,每個(gè)機(jī)器人的每項(xiàng)屬性并不統(tǒng)一。要消滅一個(gè)機(jī)器人,需要將他的每項(xiàng)屬性值都減為1,現(xiàn)在有k次操作機(jī)會(huì),每次操作可以將每個(gè)機(jī)器人的某項(xiàng)屬性值都減1,問在不超過k次操作的情況下,如何分配每項(xiàng)屬性減幾次,可以使得最終消滅最多的連續(xù)機(jī)器人序列,輸出分配攻擊方案。

???? 注意:如果不能全部消滅,則每項(xiàng)輸出0,因?yàn)橐笙谋M量少的操作數(shù),達(dá)到殺死盡量多連續(xù)的機(jī)器人。


解題:

???? RMQ,區(qū)間詢問問題,可以做到O(nlogn)復(fù)雜度預(yù)處理,O(log n)復(fù)雜度詢問,入門ST算法,可以看這篇博客,通過RMQ預(yù)處理好每項(xiàng)屬性,區(qū)間最大值。

???? 隨后詢問時(shí),只要查詢出該區(qū)間每項(xiàng)屬性的最大值,隨后將這些最大值累加,即為消滅該區(qū)間全部機(jī)器人的最小操作次數(shù)。

???? 枚舉左端點(diǎn),二分右區(qū)間,若區(qū)間需要操作數(shù)大于k,則左移右區(qū)間,縮小區(qū)間長度,若小于等于k則,右移右區(qū)間,增大區(qū)間長度。在二分過程中更新區(qū)間最優(yōu)值,同時(shí)還需記錄此時(shí)的分配情況,若區(qū)間長度相等的情況下,還需保證操作數(shù)盡量小。


代碼:


#include#include#include#include#include#include#include#include#define?LL?long?long
#define?maxn?100010
#define?sq(a)??1LL*(a)*(a)
#define?mod?1000000007
using?namespace?std;
int?arr[maxn][5],d[maxn][5][20],path[5],tmp[5];
int?n,m,k;
void?init()
{
??for(int?i=0;i<n;i++)
	??for(int?j=0;j<m;j++)
		??d[i][j][0]=arr[i][j];
??for(int?j=1;(1<<j)<=n;j++)
	??for(int?i=0;i+(1<<j)-1<n;i++)
		??for(int?k=0;k<m;k++)
			??d[i][k][j]=max(d[i][k][j-1],d[i+(1<<(j-1))][k][j-1]);
}
int?RMQ(int?le,int?ri)
{
	int?k=0,res=0;
	for(int?i=0;i<m;i++)
	{
		k=0;
		while((1<<(k+1))<=ri-le+1)
			k++;
		tmp[i]=max(d[le][i][k],d[ri-(1<<k)+1][i][k]);
		res+=tmp[i];
	}
	return?res;
}
void?update()
{				?
??for(int?j=0;j<m;j++)
	path[j]=tmp[j];
}
int?main()
{
	int?le,ri,temp,ans=0,ansk=0x3f3f3f3f;
	bool?flag=0;
	scanf("%d%d%d",&n,&m,&k);
????for(int?i=0;i<n;i++)
		for(int?j=0;j<m;j++)
			scanf("%d",&arr[i][j]);
	init();

	for(int?i=0;i<n;i++)
	{
??????le=i;
??????ri=n-1;
	??if(ri-le+1<ans)
		??break;
	??while(le>1;
		?temp=RMQ(i,mid);
		?if(tempans)
			?{
				?ansk=temp;
				?ans=mid-i+1;
				?update();
			?}
			?else?if(mid-i+1==ans)
			?{
				?if(ansk>temp)
				?{
					ansk=temp;
????????????????????update();
				?}
			?}
			?le=mid+1;
		?}
		?else
		?{
			?ri=mid-1;
			?if(ri-i+1<ans)
				?break;
		?}
	??}
	}
	printf("%d",path[0]);
	for(int?i=1;i<m;i++)
		printf("?%d",path[i]);
	printf("n");
	return?0;
}



本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

LED驅(qū)動(dòng)電源的輸入包括高壓工頻交流(即市電)、低壓直流、高壓直流、低壓高頻交流(如電子變壓器的輸出)等。

關(guān)鍵字: 驅(qū)動(dòng)電源

在工業(yè)自動(dòng)化蓬勃發(fā)展的當(dāng)下,工業(yè)電機(jī)作為核心動(dòng)力設(shè)備,其驅(qū)動(dòng)電源的性能直接關(guān)系到整個(gè)系統(tǒng)的穩(wěn)定性和可靠性。其中,反電動(dòng)勢抑制與過流保護(hù)是驅(qū)動(dòng)電源設(shè)計(jì)中至關(guān)重要的兩個(gè)環(huán)節(jié),集成化方案的設(shè)計(jì)成為提升電機(jī)驅(qū)動(dòng)性能的關(guān)鍵。

關(guān)鍵字: 工業(yè)電機(jī) 驅(qū)動(dòng)電源

LED 驅(qū)動(dòng)電源作為 LED 照明系統(tǒng)的 “心臟”,其穩(wěn)定性直接決定了整個(gè)照明設(shè)備的使用壽命。然而,在實(shí)際應(yīng)用中,LED 驅(qū)動(dòng)電源易損壞的問題卻十分常見,不僅增加了維護(hù)成本,還影響了用戶體驗(yàn)。要解決這一問題,需從設(shè)計(jì)、生...

關(guān)鍵字: 驅(qū)動(dòng)電源 照明系統(tǒng) 散熱

根據(jù)LED驅(qū)動(dòng)電源的公式,電感內(nèi)電流波動(dòng)大小和電感值成反比,輸出紋波和輸出電容值成反比。所以加大電感值和輸出電容值可以減小紋波。

關(guān)鍵字: LED 設(shè)計(jì) 驅(qū)動(dòng)電源

電動(dòng)汽車(EV)作為新能源汽車的重要代表,正逐漸成為全球汽車產(chǎn)業(yè)的重要發(fā)展方向。電動(dòng)汽車的核心技術(shù)之一是電機(jī)驅(qū)動(dòng)控制系統(tǒng),而絕緣柵雙極型晶體管(IGBT)作為電機(jī)驅(qū)動(dòng)系統(tǒng)中的關(guān)鍵元件,其性能直接影響到電動(dòng)汽車的動(dòng)力性能和...

關(guān)鍵字: 電動(dòng)汽車 新能源 驅(qū)動(dòng)電源

在現(xiàn)代城市建設(shè)中,街道及停車場照明作為基礎(chǔ)設(shè)施的重要組成部分,其質(zhì)量和效率直接關(guān)系到城市的公共安全、居民生活質(zhì)量和能源利用效率。隨著科技的進(jìn)步,高亮度白光發(fā)光二極管(LED)因其獨(dú)特的優(yōu)勢逐漸取代傳統(tǒng)光源,成為大功率區(qū)域...

關(guān)鍵字: 發(fā)光二極管 驅(qū)動(dòng)電源 LED

LED通用照明設(shè)計(jì)工程師會(huì)遇到許多挑戰(zhàn),如功率密度、功率因數(shù)校正(PFC)、空間受限和可靠性等。

關(guān)鍵字: LED 驅(qū)動(dòng)電源 功率因數(shù)校正

在LED照明技術(shù)日益普及的今天,LED驅(qū)動(dòng)電源的電磁干擾(EMI)問題成為了一個(gè)不可忽視的挑戰(zhàn)。電磁干擾不僅會(huì)影響LED燈具的正常工作,還可能對周圍電子設(shè)備造成不利影響,甚至引發(fā)系統(tǒng)故障。因此,采取有效的硬件措施來解決L...

關(guān)鍵字: LED照明技術(shù) 電磁干擾 驅(qū)動(dòng)電源

開關(guān)電源具有效率高的特性,而且開關(guān)電源的變壓器體積比串聯(lián)穩(wěn)壓型電源的要小得多,電源電路比較整潔,整機(jī)重量也有所下降,所以,現(xiàn)在的LED驅(qū)動(dòng)電源

關(guān)鍵字: LED 驅(qū)動(dòng)電源 開關(guān)電源

LED驅(qū)動(dòng)電源是把電源供應(yīng)轉(zhuǎn)換為特定的電壓電流以驅(qū)動(dòng)LED發(fā)光的電壓轉(zhuǎn)換器,通常情況下:LED驅(qū)動(dòng)電源的輸入包括高壓工頻交流(即市電)、低壓直流、高壓直流、低壓高頻交流(如電子變壓器的輸出)等。

關(guān)鍵字: LED 隧道燈 驅(qū)動(dòng)電源
關(guān)閉