Open cup #2

A

D:用前面的H去消去后面的K 然后求最长连续的M

F:在每一列/行里面求最大的数然后组成最大的和ans[]里的比求出最大的

L:并查集

J:DP背锅题 01背包 先求出M种里每种的size和last然后先last最大的放在最后 然后背包DP

long long solve(Group* groups) {
    long long* x = new long long[n + 1];
    for (int i=0; i<n+1; i++) x[i] = INFINITY;
    x[0] = 0;

    // all groups but the last; the last always goes
    // into "last" bus
    for (int i=0; i<m-1; i++)
        for (int j=n-groups[i].size; j>=0; j--) {
            long long time = max(x[j], groups[i].time);
            x[j+groups[i].size] = min(time, x[j+groups[i].size]);
        }

    //for (int i=0; i<=n; i++) cout << x[i] << " ";
    //cout << endl;

    long long answer = -1;
    for (int i=0; i<=k; i++)
        if (n - i <= k) if (x[i] < INFINITY) {
            long long total = x[i] * i + (n - i) * groups[m-1].time;
            if (answer == -1 || total < answer)
                answer = total;
        }

    return answer;
}

X[i]表示有i人在一个飞机上时的最小last

然后i从0枚举到k如果剩下的不大于K就统计total 更新答案

时间: 2024-11-05 19:23:09

Open cup #2的相关文章

HDU 2289 Cup

Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5597    Accepted Submission(s): 1787 Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we know th

ZOJ 1584:Sunny Cup 2003 - Preliminary Round(最小生成树&amp;amp;&amp;amp;prim)

Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem E: QS Network In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get connected, they

uva 6757 Cup of Cowards(中途相遇法,貌似)

uva 6757 Cup of CowardsCup of Cowards (CoC) is a role playing game that has 5 di?erent characters (Mage, Tank, Fighter,Assassin and Marksman). A team consists of 5 players (one from each kind) and the goal is to kill amonster with L life points. The

[BZOJ 3145][Feyat cup 1.5]Str 解题报告

[Feyat cup 1.5]Str DescriptionArcueid,白姬,真祖的公主.在和推倒贵看电影时突然对一个问题产生了兴趣:我们都知道真祖和死徒是有类似的地方.那么从现代科学的角度如何解释呢?自然就得研究遗传密码了.Arcueid得知了两者的DNA片段,想寻求一个DNA片段,使得其在两者的DNA中都出现过.我们知道公主的脑袋有点不太灵活,如果两个DNA片段只有一个位置不同,她也会将其认为是相同的.所以请您找出这样的最长的DNA片段吧.Input两行,每行一个字符串.Output一个

pat1011. World Cup Betting (20)

1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battl

POJ1953 World Cup Noise

这题纯暴力会超时,只需简单推一下递推公式即可,其实就是一个斐波拉契数列. World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15937   Accepted: 7861 Description Background "KO-RE-A, KO-RE-A" shout 54.000 happy football fans after their team has reached the

poj 3117 World Cup(简单数学题)

题目链接:http://poj.org/problem?id=3117 World Cup Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8634   Accepted: 4327 Description A World Cup of association football is being held with teams from around the world. The standing is based on

2014 New Air Jordans 6 World Cup Brazil For Sale

Jordan Brand has been going out of the Air Jordan 6 World Cup Brazil ordinary with some of their Retro colorways over the last few years and the trend continues. Along side the OG White/Varsity Red Retro 2s JB will be dropping few new colors with one

Cup

Cup Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 932 Accepted Submission(s): 319   Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we know the vol

Poj 3117 World Cup

1.Link: http://poj.org/problem?id=3117 2.Content: World Cup Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8778   Accepted: 4406 Description A World Cup of association football is being held with teams from around the world. The standin