01背包_The Highest Mark

source

Description

The SDOI in 20452045 is far from what it was been 3030 years ago. Each competition has tt minutes and nn problems.

The ithith problem with the original mark of Ai(Ai≤106)Ai(Ai≤106),and it decreases BiBi by each minute. It is guaranteed that it does not go to minus when the competition ends. For example someone solves the ithith problem after xx minutes of the competition beginning. He/She will get Ai?Bi?xAi?Bi?x marks.

If someone solves a problem on xx minute. He/She will begin to solve the next problem on x+1x+1 minute.

dxy who attend this competition with excellent strength, can measure the time of solving each problem exactly.He will spend Ci(Ci≤t)Ci(Ci≤t) minutes to solve the ith problem. It is because he is so godlike that he can solve every problem of this competition. But to the limitation of time, it's probable he cannot solve every problem in this competition. He wanted to arrange the order of solving problems to get the highest mark in this competition.
Input
There is an positive integer T(T≤10)T(T≤10) in the first line for the number of testcases.(the number of testcases with n>200n>200 is no more than 55)

For each testcase, there are two integers in the first line n(1≤n≤1000)n(1≤n≤1000) and t(1≤t≤3000)t(1≤t≤3000) for the number of problems and the time limitation of this competition.

There are nn lines followed and three positive integers each line Ai,Bi,CiAi,Bi,Ci. For the original mark,the mark decreasing per minute and the time dxy of solving this problem will spend.

Hint:
First to solve problem 22 and then solve problem 11 he will get 8888 marks. Higher than any other order.
Output
For each testcase output a line for an integer, for the highest mark dxy will get in this competition.

Sample Input

1
4 10
110 5 9
30 2 1
80 4 8
50 3 2

Sample Output

88

結(jié)題報(bào)告

#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
struct Node{
    int A;
    int B;
    int C;
    bool operator <(const Node &t)
    {
        return (long long)B*(t.C)>(long long)(t.B)*C;

    }
} arr[3500];
int dp[3500];
int main() {

    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n,t;
        memset(dp,0,sizeof(dp));
        scanf("%d%d",&n,&t);
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d%d",&arr[i].A,&arr[i].B,&arr[i].C );

        }
        sort(arr+1,arr+n+1);
        for(int i=1;i<=n;i++){
            for(int j=t;j>=arr[i].C;j--)
            {
                dp[j]=max(dp[j],dp[j-arr[i].C]+arr[i].A-arr[i].B*j);
            }
        }
         int ans = 0;
        for(int i = 0; i <= t; i++) {
            ans = max(ans, dp[i]);
        }
        printf("%d\n", ans);
    }
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末碘耳,一起剝皮案震驚了整個(gè)濱河市闸昨,隨后出現(xiàn)的幾起案子捅暴,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,036評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡领曼,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,046評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門蛮穿,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)庶骄,“玉大人,你說(shuō)我怎么就攤上這事践磅〉サ螅” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 164,411評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵府适,是天一觀的道長(zhǎng)羔飞。 經(jīng)常有香客問(wèn)我,道長(zhǎng)檐春,這世上最難降的妖魔是什么逻淌? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,622評(píng)論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮疟暖,結(jié)果婚禮上卡儒,老公的妹妹穿的比我還像新娘田柔。我一直安慰自己,他們只是感情好骨望,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,661評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布硬爆。 她就那樣靜靜地躺著,像睡著了一般擎鸠。 火紅的嫁衣襯著肌膚如雪缀磕。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 51,521評(píng)論 1 304
  • 那天劣光,我揣著相機(jī)與錄音虐骑,去河邊找鬼。 笑死赎线,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的糊饱。 我是一名探鬼主播垂寥,決...
    沈念sama閱讀 40,288評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼另锋!你這毒婦竟也來(lái)了滞项?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 39,200評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤夭坪,失蹤者是張志新(化名)和其女友劉穎文判,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體室梅,經(jīng)...
    沈念sama閱讀 45,644評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡戏仓,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,837評(píng)論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了亡鼠。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片赏殃。...
    茶點(diǎn)故事閱讀 39,953評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖间涵,靈堂內(nèi)的尸體忽然破棺而出仁热,到底是詐尸還是另有隱情,我是刑警寧澤勾哩,帶...
    沈念sama閱讀 35,673評(píng)論 5 346
  • 正文 年R本政府宣布抗蠢,位于F島的核電站,受9級(jí)特大地震影響思劳,放射性物質(zhì)發(fā)生泄漏迅矛。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,281評(píng)論 3 329
  • 文/蒙蒙 一敢艰、第九天 我趴在偏房一處隱蔽的房頂上張望诬乞。 院中可真熱鬧,春花似錦、人聲如沸震嫉。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,889評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)票堵。三九已至扼睬,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間悴势,已是汗流浹背窗宇。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,011評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留特纤,地道東北人军俊。 一個(gè)月前我還...
    沈念sama閱讀 48,119評(píng)論 3 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像捧存,于是被迫代替她去往敵國(guó)和親粪躬。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,901評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,497評(píng)論 0 23
  • 1. 2010年昔穴,是我人生中最艱難的一年镰官。 那一年,我因中斷工作脫產(chǎn)學(xué)習(xí)吗货,成了無(wú)工作泳唠、無(wú)收入、無(wú)存款的三無(wú)人員宙搬。日...
    黃愛(ài)春秋閱讀 660評(píng)論 1 9
  • 夜笨腥,還是那般安靜 可惜從來(lái)沒(méi)有你 天,依舊按時(shí)亮起 只是回不到過(guò)去 不知道怎么說(shuō)愛(ài)你
    SogoodIT閱讀 203評(píng)論 0 0