感觉很简单,就是讨论一下 #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…
贪心水题,每次取最短的两个绳子合并,长度缩减成一半 #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…
 Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the…
C. Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from t…
由于是输出任意一组解,可以将价值从小到大进行排序,第一个人只选第一个,第二个人选其余的.再比较一下第一个人选的元素和第二个人所选元素和是否相等即可.由于已将所有元素价值从小到大排过序,这样可以保证在有解的情况下一定可以构造出可行解. Code: #include<iostream> #include<algorithm> using namespace std; const int maxn = 100000 + 3; int a[maxn], A[maxn]; bool cmp(…
题目链接: http://codeforces.com/problemset/problem/671/A 题目大意: A和B在一张二维平面上,平面上有N个垃圾,垃圾桶只有一个在T,问把所有垃圾全扔进垃圾桶最少走多远.一次只能拿一个垃圾.允许一个人走另一个人停下来. (1 ≤ n ≤ 100 000)  (0 ≤ xi, yi ≤ 109) 题目思路: [模拟] 因为每次只能携带一个垃圾,大部分垃圾都是人扔完上一个垃圾后,从垃圾桶出发去捡的. 而最多有两个垃圾不是被人从垃圾桶出发完再扔到垃圾桶.…
题目链接:http://codeforces.com/problemset/problem/671/A 题目大意:给你两个人的位置和一个箱子的位置,然后给出n个瓶子的位置,要求让至少一个人去捡瓶子放到箱子里面去,一次只能拿一个瓶子,求把全部瓶子捡完之后的距离总和最小.解题思路:开始有两个起点A,B.除了从A或B出发拿瓶子并回到箱子距离不确定,其他时候肯定要从箱子到瓶子再回到箱子,距离就是dis(箱子到瓶子)*2.关于从A,B出发拿瓶子,分三种情况:①只有A拿②只有B拿③A拿一个瓶子,B拿一个瓶子…
一.题目 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&…
1440. [NOIP2013]积木大赛 ★★   输入文件:BlockNOIP2013.in   输出文件:BlockNOIP2013.out   简单对比时间限制:1 s   内存限制:128 MB [题目描述] [输入格式]BlockNOIP2013.in 输入文件改为BlockNOIP2013.in [输出格式]BlockNOIP2013.out 输出文件改为BlockNOIP2013.out [来源] CCF全国信息学奥林匹克联赛(NOIP2013)复赛Day2 太感动了 NOIP出这…