POJ2392

題意:奶牛們要用K個不同類型的石頭建太空電梯.每一種石頭的高度為Hi,數量為Ci,且不能放在高于Ai的地方,求最高能建多高的太空電梯.

分析:多重背包,數組標記.顯然將ai小的放在下面會更優.所以先排序.

code:

const maxh=41000;
var   cnt:array[0..maxh] of longint;h,a,c:array[0..401] of longint;f:array[0..maxh] of boolean;n,i,j,k,tmp,ans:longint;procedure swap(var a,b:longint);var   tmp:longint;begintmp:=a; a:=b; b:=tmp;end;procedure sort(l,r:longint);var   i,j,mid:longint;begini:=l; j:=r;mid:=a[(l+r)>>1];while i<=j dobeginwhile a[i]<mid do inc(i);while a[j]>mid do dec(j);if i<=j thenbeginswap(h[i],h[j]);swap(a[i],a[j]);swap(c[i],c[j]);inc(i); dec(j);end;end;if i<r then sort(i,r);if j>l then sort(l,j);end;beginreadln(n);for i:=1 to n do readln(h[i],a[i],c[i]);sort(1,n);f[0]:=true;for i:=1 to n dobeginfillchar(cnt,sizeof(cnt),0);for j:=0 to a[i] doif (f[j]=true)and(not f[j+h[i]])and(j+h[i]<=a[i])and(cnt[j]<c[i]) thenbeginf[j+h[i]]:=true;cnt[j+h[i]]:=cnt[j]+1;end;end;for i:=maxh downto 0 do if f[i] then break;writeln(i);end.

轉載于:https://www.cnblogs.com/exponent/archive/2011/08/12/2136501.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/275305.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/275305.shtml
英文地址,請注明出處:http://en.pswp.cn/news/275305.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

網絡低俗詞_從“低俗小說”中汲取7堂課,以創建有影響力的作品集

網絡低俗詞重點 (Top highlight)Design portfolios and blockbuster movies had become more and more generic. On the design side, I blame all the portfolio reviews and articles shared by “experienced” designers that repeat the same pieces of advice regardless…

Vue多個組件映射到同一個組件,頁面不刷新?

問題 在做項目的過程中,有這么一個場景&#xff1a;多個組件通過配置路由,都跳轉到同一個組件,他們之間的區別就是,傳入的參數不同.請看router對象&#xff1a; userCenterLike: {name: user-center,params: {index: 0}},userCenterHistory: {name: user-center,params: {index…

尤雨溪寫的100多行的“玩具 vite”,十分有助于理解 vite 原理

1. 前言大家好&#xff0c;我是若川。最近組織了源碼共讀活動&#xff0c;感興趣的可以加我微信 ruochuan12想學源碼&#xff0c;極力推薦之前我寫的《學習源碼整體架構系列》jQuery、underscore、lodash、vuex、sentry、axios、redux、koa、vue-devtools、vuex4、koa-compose、…

webflow如何使用_我如何使用Webflow構建輔助項目以幫助設計人員進行連接

webflow如何使用I launched Designer Slack Communities a while ago, aiming to help designers to connect with likeminded people. By sharing my website with the world, I’ve connected with so many designers. The whole experience is a first time for me, so I wa…

atmega8 例程:T1定時器 CTC模式 方波輸出

/******************************************************************* * 函數庫說明&#xff1a;ATMEGA8 T1定時器 CTC模式 方波輸出 * 版本&#xff1a; v1.00 * 修改&#xff1a; 龐輝 蕪湖聯大飛思卡爾工作室…

antd的table進行列篩選時,更新dataSource,為什么table顯示暫無數據?

我想當然地認為只要dataSource改變&#xff0c;那么<Table>組件就會重新渲染&#xff0c;但是有一種特殊情況例外&#xff1a;在onFilter()中不寫篩選條件&#xff0c;在調用filterDropdown進行列篩選的時候&#xff0c;通過handleSearch改變/保存dataSource的狀態&#…

重新構想原子化 CSS

感謝印記中文的 QC-L[1] 對本文進行翻譯&#xff0c;英文原文: English Version[2]。本文會比往期文章相對長些。這是我個人的一個重大的工具發布&#xff0c;有許多內容我想談論。如果你能花些時間讀完&#xff0c;不勝感激&#xff0c;希望能對你有所幫助 :)推薦訪問 https:/…

cv::mat 顏色空間_網站設計基礎:負空間

cv::mat 顏色空間Let’s start off by answering this question: What is negative space? It is the “empty” space between and around the subjects of an image. In the context of web design, your “subjects” are the pictures, videos, text, buttons and other e…

MVC3 上傳文件

前臺引擎采用Razor 上傳頁View&#xff1a; model System.Web.HttpContextBase{ ViewBag.Title "上傳文件";}<h2>上傳文件</h2><br /><br />*new { enctype "multipart/form-data" }比不可少&#xff0c;否則上傳文件不會成功…

Day07 - Ruby比一比:Symbol符號與String字串

前情提要&#xff1a; 第六天我們透過Ruby代碼練習public&#xff0c;protected和privatemethod時&#xff0c;發現冒號在前面的參數&#xff0c;&#xff1a;mydraft&#xff0c;&#xff1a;myspace&#xff0c;這些就是符號Symbol。在今天&#xff0c;我們就來解釋Symbol吧&…

[知乎回答] 前端是否要學習 Node.js?

大家好&#xff0c;我是若川。最近組織了源碼共讀活動&#xff0c;感興趣的可以加我微信 ruochuan12很多小伙伴都表示收獲頗豐。一起學的大多數200行左右的Node.js源碼。今天推薦這篇文章。&#xff08;剛剛在寫明天掘金要發的文章&#xff0c;差點忘記今天還沒發文。在知乎上看…

shields 徽標_我的徽標素描過程

shields 徽標Sketching is arguably the most important part of my process when it comes to logo design. In the beginning of my design career, I would actually skip this step completely and go right to the computer. I’d find myself getting stuck and then goi…

VC編程心得

VC編程心得 開始&#xff1a; 聲明變量要初始化&#xff1b; 指針變量申請空間后是不是為空&#xff08;申請不成功&#xff09;&#xff1b; 過程&#xff1a; CREATE、OPEN了的東西賦給指針變量&#xff0c;要看指針變量是否為空&#xff1b; 指針變量在調用其方法之前&#…

叮咚,系統檢測到 npm 有更新,原理揭秘!

大家好&#xff0c;我是若川。最近組織了源碼共讀活動&#xff0c;感興趣的可以加我微信 ruochuan12本文來自V同學投稿的源碼共讀第六期筆記&#xff0c;寫得很有趣。現在已經進行到第十期了。你或許經常看見 npm 更新的提示。npm 更新提示面試官可能也會問你&#xff0c;組件庫…

ui設計未來十年前景_UI設計的10條誡命

ui設計未來十年前景重點 (Top highlight)The year is approximately 1,300 BC when Moses received the 10 UI design commandments from the almighty design gods. The list was comprised of best practices that only the most enlightened designers would be aware of.當…

w3ctech 2011 北京站(組圖)

門前的牌子大廳一推低價技術書籍會場嘉賓席人漸漸到齊準備工作w3c中國區負責人 安琪 第一個演講焦峰同學分享了瀏覽器兼容性的相關問題石川同學分享的是JQuery的相關內容攝影哥微博大屏幕&#xff0c;有亮點哦。。。MBP啊有木有&#xff5e;&#xff5e;&#xff5e;貘大現場提…

Linux設備驅動之IIO子系統——IIO框架及IIO數據結構

Linux設備驅動之IIO子系統——IIO框架及IIO數據結構由于需要對ADC進行驅動設計&#xff0c;因此學習了一下Linux驅動的IIO子系統。本文翻譯自《Linux Device Drivers Development 》--John Madieu&#xff0c;本人水平有限&#xff0c;若有錯誤請大家指出。 IIO Framework 工業…

瀏覽器中的 ESM

大家好&#xff0c;我是若川。最近組織了源碼共讀活動&#xff0c;感興趣的可以加我微信 ruochuan12早期的web應用非常簡單&#xff0c;可以直接加載js的形式去實現。隨著需求的越來越多&#xff0c;應用越做越大&#xff0c;需要模塊化去管理項目中的js、css、圖片等資源。這里…

理解面向連接和無連接協議之間的區別

理解面向連接和無連接協議之間的區別 網絡編程中最基本的概念就是面向連接&#xff08;connection-oriented&#xff09;和無連接&#xff08;connectionless&#xff09;協議。 面向連接和無連接指的都是協議。也就是說&#xff0c;這些術語指的并不是無理介質本身&#xff0c…

標記圖標_標記您的圖標

標記圖標Not labeling your icons is the same as assuming that we are all fluent in ancient hieroglyphics. Are you? Can you just walk up to Cleopatras needle and read it like you could read a childrens book? Even emojis, our modern hieroglyphics dont mean …