1440. [NOIP2013]积木大赛 ★★   输入文件:BlockNOIP2013.in   输出文件:BlockNOIP2013.out   简单对比时间限制:1 s   内存限制:128 MB [题目描述] [输入格式]BlockNOIP2013.in 输入文件改为BlockNOIP2013.in [输出格式]BlockNOIP2013.out 输出文件改为BlockNOIP2013.out [来源] CCF全国信息学奥林匹克联赛(NOIP2013)复赛Day2 太感动了 NOIP出这…
LOJ2611. NOIP2013 积木大赛 LINK 题目大意是给你一个目标状态数组 每次你可以选择一个连续区间加上一个值,求最小操作次数 我是神奇的脑子 最近做数据结构疯了 然后看见这题就数据结构了 好像网上还没有这种做法 逆向考虑这个过程 我们直接从目标数组删去一个连续区间 我们先考虑对于一个区间肯定一次删掉min(l to r)是最优的情况 假设区间最小的位置是pos,那么删除后pos变成了0 所以可以递归成l to pos−1和pos+1 to r两个区间 累加上pos的高度并且区间减…
贪心水题,每次取最短的两个绳子合并,长度缩减成一半 #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…
题目描述 春春幼儿园举办了一年一度的“积木大赛”.今年比赛的内容是搭建一座宽度为n的大厦,大厦可以看成由n块宽度为1的积木组成,第i块积木的最终高度需要是hi. 在搭建开始之前,没有任何积木(可以看成n块高度为 0 的积木).接下来每次操作,小朋友们可以选择一段连续区间[l, r],然后将第第 L 块到第 R 块之间(含第 L 块和第 R 块)所有积木的高度分别增加1. 小 M 是个聪明的小朋友,她很快想出了建造大厦的最佳策略,使得建造所需的操作次数最少.但她不是一个勤于动手的孩子,所以想请你帮…
题目描述 春春幼儿园举办了一年一度的“积木大赛”.今年比赛的内容是搭建一座宽度为n的大厦,大厦可以看成由n块宽度为1的积木组成,第i块积木的最终高度需要是hi. 在搭建开始之前,没有任何积木(可以看成n块高度为 0 的积木).接下来每次操作,小朋友们可以选择一段连续区间[l, r],然后将第第 L 块到第 R 块之间(含第 L 块和第 R 块)所有积木的高度分别增加1. 小 M 是个聪明的小朋友,她很快想出了建造大厦的最佳策略,使得建造所需的操作次数最少.但她不是一个勤于动手的孩子,所以想请你帮…
一.题目 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…
题目链接:UVA - 11389 题意描述:有n个司机,n个早班路线和n个晚班路线,给每个司机安排一个早班路线和一个晚班路线,使得每个早班路线和晚班路线只属于一个司机.如果一个司机早班和晚班总的驾驶时间超过d,那么超出的时间按每小时r元付给司机.求最小的费用. 算法分析:一枚贪心的小水题.对早班路线的时间按照从大到小排序,对晚班路线的时间按照从小到大排序,然后就可以了. #include<iostream> #include<cstdio> #include<cstring&…
蓝书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…
感觉很简单,就是讨论一下 #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…