HOJ13907 Diana and the Golden Apples

简单背包题,写上是因为这个板子还不错,本校OJ有个恶心的地方,单kas输入的时候写成多kas会wa~~

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
const int maxn=3e4+10;
const int N=1e3+10;
typedef long long LL;
int wei[N],val[N],dp[maxn];
int main()
{
    freopen("input.txt","r",stdin);
    int l,td,th,n,d;
    scanf("%d%d%d%d%d",&l,&td,&th,&n,&d);
    memset(dp,0,sizeof dp);
    if(td>=th){printf("Diana marries Humperdonkey\n");return 0;}
    int w,x;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&w,&x);
        wei[i]=(l-x)*w*d;
        val[i]=w;
    }
    int m=(th-td)*l-1;
    for(int i=0; i<n; i++)
    {
        for(int j=m; j>=wei[i]; j--)
            dp[j] = max(dp[j],dp[j-wei[i]]+val[i]);
    }
    printf("%d\n",dp[m]);
    return 0;
}
时间: 2024-10-10 05:38:01

HOJ13907 Diana and the Golden Apples的相关文章

Manifesto of the Communist Party

A spectre is haunting Europe – the spectre of communism. All the powers of old Europe have entered into a holy alliance to exorcise this spectre: Pope and Tsar, Metternich and Guizot, French Radicals and German police-spies. Where is the party in opp

Pick apples 第三届acm省赛

Description Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because she has never seen so many apples before. Each ki

hdoj 3820 Golden Eggs 【双二分图构造最小割模型】

Golden Eggs Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 505    Accepted Submission(s): 284 Problem Description There is a grid with N rows and M columns. In each cell you can choose to put

uva 11383 Golden Tiger Claw (KM算法)

uva 11383 Golden Tiger Claw 题目大意:给定一个N×N的矩阵,每个格子里都有一个正整数w(i,j).你的任务是给每行确定一个整数row(i), 每列也确定一个整数col(i),使得对于格子(i,j),w(i,j)<=row(i)+col(j).所有row(i)和col(j)的总和最小. 解题思路:KM算法. #include <cstdio> #include <cstring> #include <algorithm> #include

HDU 5303 Delicious Apples(贪心 + 背包 2015多校啊)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5303 Problem Description There are n apple trees planted along a cyclic road, which is L metres long. Your storehouse is built at position 0 on that cyclic road. The ith tree is planted at position xi,

Codeforces Round #257 (Div. 2) E题:Jzzhu and Apples 模拟

E. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to

CodeForces 23C Oranges and Apples 抽屉原理

题目链接:点击打开链接 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <iostream> #include <map> #include <set> #include <math.h> using namespace std; #define inf 10000000 #define l

Codeforces Round #325 (Div. 2) E. Alice, Bob, Oranges and Apples

E. Alice, Bob, Oranges and Apples Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining frui

HDOJ 4814 Golden Radio Base

利用题目中给出的公式和hint可以得到两个有用的公式: phi^(n) = phi^(n-1)+phi^(n-2) 2*(phi^n) = phi^(n+1)+phi^(n-2) 可以计算出phi^100远大于10^9,所以推测最后得到的phi进制的数整数和小数部分应该不会超过100位,事实表明,50位就能过. 所以最终变成了简单的模拟. Golden Radio Base Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 3276