一.题目 Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10,000) weeks, the price of milk and labor will fluctuate weekly such that it will cost the company C_i (1 <= C_i <= 5,0…
贪心水题,每次取最短的两个绳子合并,长度缩减成一半 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <string> #include <map> using namespace std; +; int a[maxn]; int main() { int n; scanf("%d",&am…
1440. [NOIP2013]积木大赛 ★★   输入文件:BlockNOIP2013.in   输出文件:BlockNOIP2013.out   简单对比时间限制:1 s   内存限制:128 MB [题目描述] [输入格式]BlockNOIP2013.in 输入文件改为BlockNOIP2013.in [输出格式]BlockNOIP2013.out 输出文件改为BlockNOIP2013.out [来源] CCF全国信息学奥林匹克联赛(NOIP2013)复赛Day2 太感动了 NOIP出这…
题目:http://poj.org/problem?id=2393 题意:N周,每周生成牛奶(任意!),每周成本为c_i(1~5000),每周出货 y_i:出货可以使用该周生产的,也可以用之前的储存的牛奶,每周存储 每单位牛奶需要 S 价格.问,N周最小的成本是多少? 题解:贪心策略,维持每周 的最低单位成本,本周的单位成本 为 min(上周单位成本 + 存储S,本周成本) AC代码: #include <iostream> #include <cstdio> #include &…
蓝书P1, 很简单的一个贪心选择,用能力小的去砍小的.本来想双重循环,哎,傻逼了,直接遍历选手,碰到能砍的就砍掉. #include <stdio.h> #include <algorithm> using namespace std; #define MAXN 20005 int n,m; int nn[MAXN],mm[MAXN]; int main() { freopen("input.txt","r",stdin); while(sc…
题目链接:UVA - 11389 题意描述:有n个司机,n个早班路线和n个晚班路线,给每个司机安排一个早班路线和一个晚班路线,使得每个早班路线和晚班路线只属于一个司机.如果一个司机早班和晚班总的驾驶时间超过d,那么超出的时间按每小时r元付给司机.求最小的费用. 算法分析:一枚贪心的小水题.对早班路线的时间按照从大到小排序,对晚班路线的时间按照从小到大排序,然后就可以了. #include<iostream> #include<cstdio> #include<cstring&…
感觉很简单,就是讨论一下 #include <stdio.h> #include <string.h> #include <algorithm> #include <math.h> using namespace std; typedef pair<double,int>pii; ; double x[N],y[N]; pii a[N],b[N]; double dis(double x1,double y1,double x2,double y…
B. Ciel and Flowers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make seve…
UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r++; printf("Case %d: %d\n",++kas,r); } ; } LA 3602 DNA Consensus String 贪心构造,每一位上选出现次数最多的. #include<bits/stdc++.h> using namespace std; ,ma…
hdu_1800 简单排一下序,从大开始把比他小的都访问一遍,ans++: #include <iostream> #include <stdio.h> #include <algorithm> using namespace std; struct dat { int level; int visit; }data[]; bool cmp(dat a, dat b) { return a.level > b.level; } int main() { int n…