zoj 1375||poj 1230(贪心)】的更多相关文章

Pass-Muraille Time Limit: 2 Seconds      Memory Limit: 65536 KB In modern day magic shows, passing through walls is very popular in which a magician performer passes through several walls in a predesigned stage show. The wall-passer (Pass-Muraille) h…
题目连接:problemId=542" target="_blank">ZOJ 1542 POJ 1861 Network 网络 Network Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Andrew is working as system administrator and is planning to establish a new network in his com…
题目链接: PKU:http://poj.org/problem?id=1862 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=543 Description Our chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian -…
https://vjudge.net/problem/ZOJ-1375 In modern day magic shows, passing through walls is very popular in which a magician performer passes through several walls in a predesigned stage show. The wall-passer (Pass-Muraille) has a limited wall-passing en…
Arctic Network The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a radio transceive…
/* * POJ_1230.cpp * * Created on: 2013年10月9日 * Author: Administrator */ #include <iostream> #include <cstdio> using namespace std; int map[105][105]; int main() { int t, n, k, x, y, x1, y1, max_x, max_y, sum_s; scanf("%d", &t); w…
(- ̄▽ ̄)-* (注意下面代码中关于iterator的用法,此代码借鉴某大牛) #include<iostream> #include<cstdio> #include<vector> #include<cstring> using namespace std; struct Wall { int row;//表示墙在哪行 int left; int right; }; ];//保存每列的墙数 vector<Wall> wall; int ma…
Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 59725   Accepted: 20273 Description A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are alway…
水题三题: 1.给你B和N,求个整数A使得A^n最接近B 2. 输出第N个能被3或者5整除的数 3.给你整数n和k,让你求组合数c(n,k) 1.poj 3100 (zoj 2818) Root of the Problem: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2818 http://poj.org/problem?id=3100 #include<cstdio> #include<cmath>…
题意:FJ希望它的牛做一些清洁工作.有N只牛和T个时间段,每只牛可以承担一段时间内的工作.FJ希望让最小数量的牛覆盖整个T,求出其数量.若无法覆盖整个T,则输出-1. 分析:首先要注意T表示T个时间段,也就是说1就是一个时间段,而[1, 2]是两个时间段.在这个问题上,我们要做到的是用最小的牛覆盖整个区间.比较容易想到的是先将牛按开始时间排序,因为如果一开始就覆盖不了那么后续就没有意义可以直接输出-1.贪心选取在满足当前开始时间的前提下,其结束时间的大的牛,因为在满足开始前提下,当然是覆盖得越多…
/* 贪心.... 处理处每个点按照最大距离在x轴上的映射 然后我们就有了一些线段 目的是选取尽量少的点 使得每个线段内都有点出现 我们按照左端点排序 然后逐一处理 假设第一个雷达安在第一个线段的右端点 若下一条与之无交点 则再按一个雷达 若完全覆盖 贪心的 我们把雷达移动到下一条的右端点 这样这个雷达就又多覆盖了一个岛 */ #include<iostream> #include<cstdio> #include<cstring> #include<algori…
Yogurt factory Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8205   Accepted: 4197 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…
Cleaning Shifts Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15143   Accepted: 3875 Description Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one co…
最小生成树,用了Kruskal算法.POJ上C++能过,G++不能过... 算出每两个圆心之间的距离,如果距离小于两半径之和,那么这两个圆心之间的距离直接等于0,否则等于距离-R[i]-R[j]. #include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> using namespace std; ; struct abc{ int start, end; double…
Numbers Time Limit: 2 Seconds      Memory Limit: 65536 KB DreamGrid has a nonnegative integer n . He would like to divide n into m nonnegative integers a1,a2,...am and minimizes their bitwise or (i.e.a1+a2+...+am=n  and a1 OR a2 OR a3...OR am should…
做法一:直接贪心,按照利润排序,然后直接尽量给每个活动安排到最晚的时间即可.时间复杂度O(n * d)当d都为10000时,很容易超时.由于这题数据比较水,所有贪心未超时. AC代码 #include <cstdio> #include <cmath> #include <cctype> #include <algorithm> #include <cstring> #include <utility> #include <st…
http://poj.org/problem?id=1456 #include<cstring> #include<iostream> #include<algorithm> using namespace std; struct nod { int a; int d; }; bool cmp(nod x,nod y) { return x.a>y.a; } int main() { nod aa[]; int n; while(cin>>n) { ]…
贪心.能凑成一组就算一组 Unrhymable Rhymes Time Limit: 10 Seconds      Memory Limit: 32768 KB      Special Judge An amateur poet Willy is going to write his first abstract poem. Since abstract art does not give much care to the meaning of the poem, Willy is plan…
题目链接: http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3946 题解: 用dijkstra跑单元最短路径,如果对于顶点v,存在一系列边(ui,v)使得dis[v]最小(dis[v]表示0到v的距离).这些边能且只能选一条,那么我们自然应该选cost最小的那个边了. #include<iostream> #include<cstdio> #include<cstring> #include<…
题意:有n个商品,每个商品如果能在截止日期之前售出就会获得相应利益,求能获得的最大利益 一开始对每个时间进行贪心,后来发现后面的商品可以放到之前来卖,然后就wa了 这里就直接对价格排序,把物品尽量放到最后卖,如果在这个时间有物品卖了,就往前卖,直到前面所有的时间都满了 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath>…
Optiver sponsored problem. After years of hard work Optiver has developed a mathematical model that allows them to predict wether or not a company will be succesful. This obviously gives them a great advantage on the stock market. In the past, Optive…
题意:给定n个商品的deadline和profit,求每天卖一件的情况下的最大获利 显然是一道贪心 按deadline从小到大排序好,动态维护小根(profit)堆的大小<=当前deadline的天数,往里面符合条件的尽可能塞更优解 注意有n为0的情况 还有脑抽导致判断条件缺斤少两,下次不要这样了 /*H E A D*/ struct Node{ ll p,d,id; }a[maxn]; bool cmp(Node a,Node b){ if(a.d!=b.d)return a.d<b.d;…
                                                B - Team Formation Description For an upcoming programming contest, Edward, the headmaster of Marjar University, is forming a two-man team from N students of his university. Edward knows the skill level…
Digging Time Limit: 2 Seconds      Memory Limit: 65536 KB When it comes to the Maya Civilization, we can quickly remind of a term called the end of the world. It's not difficult to understand why we choose to believe the prophecy (or we just assume i…
poj : http://poj.org/problem?id=1523 如果无向图中一个点 u 为割点 则u 或者是具有两个及以上子女的深度优先生成树的根,或者虽然不是一个根,但是它有一个子女 w, 使得low[w] >= dfn[u]; 其中low[u] 是指点 u 通过回边所能达到的 最小深度优先数,dfn[u]是指 点u 当前所处的 深度优先数: low[u] 是在递归回退时计算出来的,dfn[u] 是在递归时直接计算的. low[u] = min { dfn[u]; min{  low…
思路: 贪心 对于每个波浪 ans+=最大值-最小值 注意最后一定是选最大值 //By SiriusRen #include <cstdio> using namespace std; int n,a[150500],flag,ans; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&a[i]); for(int i=1;i<=n;i++) if(fla…
题意: 思路: 1. 贪心 我们考虑肯定是走最近的最合适 想象自己是一个黑一日游的司机: 1.如果有乘客要上车,那么就让他上,收钱! 2.如果超载了,把距目的地最远的几个乘客踢下去,退钱. 3.行驶到下一站 (摘自http://blog.sina.com.cn/s/blog_9d987af5010158ih.html) 多么生动形象-. 用multiset乱搞就可以了(我代码写得很丑 慎看) 2 乱想的.. 我觉得可以用最大费用流+消圈来搞 (然而并不会 (也不能证明正确性) 也很可能会T )…
贪心好题 ---. 思路: 从大到小凑C 如果不够 再从小到大补满(超过)C //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n,c,ans,flag,vis[21]; struct Money{int amount,value;}money[100]; bool cmp(Money a,Money b){return a.…
题意: 思路: 贪心 能不覆盖的就不盖 写得很乱 左闭右开的 temp //By SiriusRen #include <queue> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n,l,temp,ans; struct Node{int from,to;}node[10050]; priority_queue<Node>pq…
Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5989   Accepted: 3056 Description Saruman the White must lead his army along a straight path from Isengard to Helm's Deep. To keep track of his forces, Saruman distributes se…