sgu259 Printed PR    贪心】的更多相关文章

link:http://acm.sgu.ru/problem.php?contest=0&problem=259 思路就是贪心. 首先要读懂题目,输入的方式,把样例读懂. 第一,打印的总时间一定.需要做的就是送出的时间尽可能的重合,这样总时间就会更少.所以,送出时间长的要尽可能的先打印,按照送出时间从大到小排序就可以了. /* * ===================================================================================…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
10020 Given several segments of line (int the X axis) with coordinates [Li, Ri]. You are to choose the minimalamount of them, such they would completely cover the segment [0, M].InputThe first line is the number of test cases, followed by a blank lin…
Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描述 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…
F - Supermarket Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1456 Appoint description:  System Crawler  (2015-11-30) Description A supermarket has a set Prod of products on sale. It earns a p…
B. War of the Corporations 题目连接: http://www.codeforces.com/contest/625/problem/B Description A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the…
Given several segments of line (int the X axis) with coordinates [Li, Ri]. You are to choose the minimal amount of them, such they would completely cover the segment [0, M].InputThe first line is the number of test cases, followed by a blank line.Eac…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud    Banana Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a…
 Minimal coverage  The Problem Given several segments of line (int the X axis) with coordinates [Li,Ri]. You are to choose the minimal amount of them, such they would completely cover the segment [0,M]. The Input The first line is the number of test…
题目:https://loj.ac/problem/3059 一段 A 选一个 B 的话, B 是这段 A 的平均值.因为 \( \sum (A_i-B)^2 = \sum A_i^2 - 2*B \sum A_i + len*B^2 \) ,这是关于 B 的二次方程,对称轴是 \( B = - \frac{-2*\sum A_i}{2*len} \) ,恰是 A 的平均值. 所以自己前 10 分写了 “ dp[ i ][ j ] 表示前 i 个 A .最后一段的 B = j ” 的 DP ,…
题目:https://www.luogu.org/problemnew/show/P1316 题意: 给定a个点的坐标(在一条直线上),现在要选b个点,问这b个点的最近距离的最大值是多少. 思路: 感觉数据量大的题目要大胆去考虑二分答案. 题目没有说给定的坐标有序,所以要先排个序. 然后二分答案,贪心的验证这个距离是不是可行的. 统计距离超过当前值的点有多少个,如果少于b说明取不到当前的答案. 这里不需要去考虑他们的最小值是不是刚好是当前值,因为最小值一定是大于等于当前答案的,如果不等于的化,那…
题目链接:http://poj.org/problem?id=1456 Time Limit: 2000MS Memory Limit: 65536K Description A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of tim…
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exactly k of t…
Supermarket Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10725 Accepted: 4688 Description A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integr…
Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描写叙述 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 s…
[BZOJ2151]种树(贪心) 题面 BZOJ 题解 如果没有相邻不能选的限制,那么这就是一道傻逼题. 只需要用一个堆维护一下就好了. 现在加上了相邻点的限制,那么我们就对于当前位置加入一个撤销操作. 怎么撤销呢? 如果我们选择了一个点,那么我们就把他前后两个位置删去, 然后将当前点合并为\(a[last]+a[next]-a[now]\)的权值. 如果下次选择了这个位置的话,就可以认为撤销了选择\(now\)这个位置, 转而选择了相邻的两个位置. 用一个链表维护前驱后继,堆维护答案即可. #…
A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to a…
C. Tanya and Toys 题目连接: http://www.codeforces.com/contest/659/problem/C Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new col…
D. Running with Obstacles 题目连接: http://www.codeforces.com/contest/637/problem/D Description A sportsman starts from point xstart = 0 and runs to point with coordinate xfinish = m (on a straight line). Also, the sportsman can jump - to jump, he should…
http://new.tyvj.cn/p/2065 我就不说我很sb的用线段树来维护值...... 本机自测的时候想了老半天没想出怎么维护点在所有区间被多少区间包含的方法.最后一小时才想出来线段树(果然太弱) .. 首先想到贪心,答案一定是某个区间的右端点...(这个很容易想也容易证,我就不说了.....) 然后按右端点排序 然后我维护了个左端点前缀和,将来枚举每一个右端点的时候所得到的答案就是sum[n]-sum[i]-he+ge*a[i].r he表示包含右端点的所有区间的左端点之和,ge表…
复制书稿(book) 时间限制: 1 Sec  内存限制: 128 MB提交: 3  解决: 1[提交][状态][讨论版][命题人:quanxing] 题目描述 现在要把m本有顺序的书分给k个人复制(抄写),每一个人的抄写速度都一样,一本书不允许给两个(或以上)的人抄写,分给每一个人的书,必须是连续的,比如不能把第一.第三和第四本书给同一个人抄写. 现在请你设计一种方案,使得复制时间最短.复制时间为抄写页数最多的人用去的时间.   输入 第一行两个整数m,k:(k≤m≤500) 第二行m个整数,…
Supermarket Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17634   Accepted: 7920 题目链接:http://poj.org/problem?id=1456 Description: A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a…
[SinGuLaRiTy-1024] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. [POJ 2709] 颜料 (Painter) 题目描述 杂货店出售一种由N(3<=N<=12)种不同颜色的颜料,每种一瓶(50ML),组成的颜料套装.你现在需要使用这N种颜料:不但如此,你还需要一定数量的灰色颜料.杂货店从来不出售灰色颜料——也就是它不属于这N种之一.幸运的是,灰色颜料是比较好配置的,如果你取出三种不同颜色的颜料各x ml,混合起来就…
题目传送门 题目大意:先提供一个数组,让你造一个数组,这个数组的要求是 1 各元素之间都互质  2  字典序大于等于原数组  3 每一个元素都大于2 思路: 1.两个数互质的意思就是没有公因子.所以每确定一个数字之后,就把这个数字的所有公因子全部用vis数组标记一下. 2.每一次找数字都是从a[i]开始找,如果a[i]符合条件则下一个,如果不符合条件就a[i]+1,暴力枚举(贪心),如果有一个地方是大于原数组的,之后的所有数字则从最小的开始找就可以了. 3.找公因子的方法是素数筛法的改编. #i…
Supermarket Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1456 Description A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx…
链接: http://acm.timus.ru/problem.aspx?space=1&num=1303 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26733#problem/D D - Minimal Coverage Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice UR…
直接贪心.先想想最后平衡的时候,如果知道了总重量,那么每一个结点的重量其实也就确定了. 每个结点在左在右其实都不影响,只和层数有关.现在反过来,如果不修改某个结点,那么就可以计算出总质量,取总质量出现次数最多的保持不变. /********************************************************* * --------------Tyrannosaurus--------- * * author AbyssalFish * ****************…
题目描述 有一家专卖一种商品的店,考虑连续的n天.第i天上午会进货Ai件商品,中午的时候会有顾客需要购买Bi件商品,可以选择满足顾客的要求,或是无视掉他.如果要满足顾客的需求,就必须要有足够的库存.问最多能够满足多少个顾客的需求. 输入 第一行一个正整数n (n<=250,000).第二行n个整数A1,A2,...An (0<=Ai<=10^9).第三行n个整数B1,B2,...Bn (0<=Bi<=10^9). 输出 第一行一个正整数k,表示最多能满足k个顾客的需求.第二行…
题目链接:http://poj.org/problem?id=1456 Supermarket Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13736   Accepted: 6206 Description A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a d…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2151 似乎是半年+前讲过的.(然而看到的时候却不会了) 考虑贪心,限制就是不能选两边的.如果选了最大的又要反悔,一定不可能是要只选旁边的一个,而是把两个都选了: 所以选了这个以后,把两边的打上标记表示不能选,往堆里加入一个值为 两边的值-自己的值 的元素表示反悔选择即可. 维护两边是谁,自己用了链表.也许这就是自己很慢的原因? #include<iostream> #include<…