poj 3104 dring 二分】的更多相关文章

Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7684   Accepted: 1967 Description It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has d…
题目链接:http://poj.org/problem?id=3104                                                                                                      Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11128   Accepted: 2865 Description It is very…
http://poj.org/problem?id=3104 题目大意: 有n件衣服,每件有ai的水,自然风干每分钟少1,而烘干每分钟少k.求所有弄干的最短时间. 思路: 注意烘干时候没有自然风干. 能够理解为烘干时每分钟掉(k-1)的水. 这样每件衣服每分钟就都掉1水了. 二分枚举最小值就可以. #include<cstdio> #include<algorithm> using namespace std; const int MAXN=100000+10; int a[MAX…
传送门 表示又是神题一道 Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9327   Accepted: 2364 Description It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring proces…
题目链接:click here~~ [题目大意]: 题意:有一些衣服,每件衣服有一定水量,有一个烘干机,每次能够烘一件衣服,每分钟能够烘掉k单位水. 每件衣服没分钟能够自己主动蒸发掉一单位水, 用烘干机烘衣服时不蒸发.问最少须要多少时间能烘干全部的衣服. [解题思路]: 题目数据较大.常规方法肯定会TE.首先能够想到二分枚举答案.枚举时间mid值,(一般二分的题目,题目叫你求什么,就二分什么就能够了) 那么相应两种方法 1:自然风干.2:吹风机吹干 若一件衣服的水量小于mid,则自然风干就可以,…
TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13262   Accepted: 6412 Description Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his toys away w…
poj 2049(二分+spfa判负环) 给你一堆字符串,若字符串x的后两个字符和y的前两个字符相连,那么x可向y连边.问字符串环的平均最小值是多少.1 ≤ n ≤ 100000,有多组数据. 首先根据套路,二分是显然的.然后跑一下spfa判断正环就行了. 然而我被no solution坑了十次提交.. #include <cctype> #include <cstdio> #include <cstring> using namespace std; const in…
[题目链接] http://poj.org/problem?id=3104 [题目大意] 给出n件需要干燥的衣服,烘干机能够每秒干燥k水分, 不在烘干的衣服本身每秒能干燥1水分 求出最少需要干燥的时间. [题解] 考虑将烘干机的烘干效应变为k-1,那么就是每件衣服在每秒都会自动减少一水分 如果我们知道最少需要的时间,那么每件衣服自己减少的水分数量就知道了, 在除去自然减少的水分之后,看看还需要多少k-1的水分减少才能烘干全部的衣服就可以了, 因此我们二分这个答案,验证是否可行即可. [代码] #…
题目链接:http://poj.org/problem?id=3104 Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9440   Accepted: 2407 Description It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afrai…
Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 12568   Accepted: 3243 Description It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has…
<题目链接> 题目大意: 有一些衣服,每件衣服有一定水量,有一个烘干机,每次可以烘一件衣服,每分钟可以烘掉k滴水.每件衣服没分钟可以自动蒸发掉一滴水,用烘干机烘衣服时不蒸发.问最少需要多少时间能烘干所有的衣服. 解题分析: 本题用二分答案求解,解题思路就是二分时间,再对每个物品依据当前二分的时间进行判断,如果该物品水量小于等于总时间,那么就等其自然风干即可,如果大于总时间,那么要使当前枚举的答案成立,该衣服必然要消耗一定的机器清洗时间,算出所有衣服需要消耗的时间,将其与枚举的答案比较,即可判断…
题意:有N件湿的衣服,一台烘干机.每件衣服有一个湿度值.每秒会减一,如果用烘干机,每秒会减k.问最少多久可以晒完. 题解:二分.首先时间越长越容易晒完. 其次判定函数可以这样给出:对于答案 X,每一个湿度大于X的衣服都要被烘干.所以可以直接统计烘干机被用的总时间,如果其大于X则返回0. 注意向下取整细节. #define _CRT_SECURE_NO_WARNINGS #include<cstring> #include<cctype> #include<cstdlib>…
Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 22163   Accepted: 5611 Description It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has…
题目大意:你有一台机器可以烘干衣物,现在有n个衣物需要烘干,每件衣服都有一个值表示含水量,烘干机一秒可以烘干k滴水,一件衣服不在烘干机上时会每秒自动蒸发一滴水,求最少用多少时间烘干所有衣服. 分析: 二分总时间,我们知道,如果一件衣服的含水量不超过总时间,就没有必要用烘干机烘干.对于超过的衣服,我们设它在烘干机上烘的时间为x,自己蒸发的时间为mid-x(mid为二分的时间),如果能烘干衣服,则可得到关系k*x+mid-x>=a[i],得到x>=(a[i]-mid)/(k-1),因为我们希望在能…
Drying 直接上中文 Descriptions 每件衣服都有一定单位水分,在不使用烘干器的情况下,每件衣服每分钟自然流失1个单位水分,但如果使用了烘干机则每分钟流失K个单位水分,但是遗憾是只有1台烘干机,每台烘干机同时只能烘干1件衣服,请问要想烘干N件衣服最少需要多长时间? 输入 多组输入 第一行输入N,表示有N件衣服,第二行输入N件衣服的水分ai,第三行表示烘干机每分钟烘干水分K 其中1 ≤ N ≤ 100 000,1 ≤ ai ≤ 10^9,1 ≤ K≤ 10^9输出 输出 烘干N件衣服…
链接:http://poj.org/problem?id=3122 Pie Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10448   Accepted: 3694   Special Judge Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N…
http://poj.org/problem?id=2318 TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10178   Accepted: 4880 Description Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child…
POJ 1759 Garland  这个题wa了27次,忘了用一个数来储存f[n-1],每次由于二分都会改变f[n-1]的值,得到的有的值不精确,直接输出f[n-1]肯定有问题. 这个题用c++交可以过,g++交过不了, f[i]=2+2*f[i-1]-f[i-2]; f[0]=A,f[1]=x; 二分枚举x的值,最终得到B的值(不是f[n-1]), 上述递推式是非齐次的二阶递推式,解其齐次特征方程,可以得到f[n-1]的齐次时的表达式,对于非齐次的,目前我还没法求出通式, B与f[n-1]的关…
Matrix Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 8674   Accepted: 2634 Description Given a N × N matrix A, whose element in the i-th row and j-th column Aij is an number that equals i2 + 100000 × i + j2 - 100000 × j + i × j, you ar…
Median Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12453   Accepted: 4357 Description Given N numbers, X1, X2, ... , XN, let us calculate the difference of every pair of numbers: ∣Xi - Xj∣ (1 ≤ i < j ≤ N). We can get C(N,2) differenc…
题目链接: http://poj.org/problem?id=2452 题意:在区间[1,n]上找到满足 a[i]<a[k]<a[j] (i<=k<=j) 的最大子区间 (j-i)如不存在输出 -1. 思路:枚举i,找到 i右边第一个不大于(不是小于) a[i]的数a[k](二分查找+RMQ某段区间的最小值是否小于a[i].最后确定到一个点),于是我们可以得到在区间[i,k-1]范围内的数都会大于 a[i] ,所以对于下标i,它对应的最长区间必定在[i,k-1]之间. 所以,我们…
Evacuation 题目连接: http://poj.org/problem?id=3057 Description Fires can be disastrous, especially when a fire breaks out in a room that is completely filled with people. Rooms usually have a couple of exits and emergency exits, but with everyone rushin…
                                                                                                     Median Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7423   Accepted: 2538 Description Given N numbers, X1, X2, ... , XN, let us calcu…
地址 http://poj.org/problem?id=3061 解法1 使用双指针 由于序列是连续正数 使用l r 表示选择的子序列的起始 每当和小于要求的时候 我们向右侧扩展 增大序列和 每当和大于等于要求的时候 我们将子序列左边的数字剔除 看能是在减少长度情况下 还能保持子序列和满足要求 这样在指定起点下的满足要求的最短子序列和都会被记录 然后在比较出最短长度的子序列 如图 代码 #include <iostream> #include <vector> #include…
Median Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5118   Accepted: 1641 Description Given N numbers, X1, X2, ... , XN, let us calculate the difference of every pair of numbers: ∣Xi - Xj∣ (1 ≤ i < j ≤ N). We can get C(N,2)differences…
Matrix Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 5724   Accepted: 1606 Description Given a N × N matrix A, whose element in the i-th row and j-th column Aij is an number that equals i2 + 100000 × i + j2 - 100000 × j + i × j, you ar…
E - River Hopscotch POJ - 3258 Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes place on a long, straight river with a rock at the start and…
Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system (x1, x2, x3, x4, x5) that verifies the equation, xi∈[-50,…
Chessboard Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 12800   Accepted: 4000 Description Alice and Bob often play games on chessboard. One day, Alice draws a board with size M * N. She wants Bob to use a lot of cards with size 1 * 2…
Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7959   Accepted: 2014 Description It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has d…