Straight Master (贪心)】的更多相关文章

题目如下:A straight is a poker hand containing five cards of sequential rank, not necessarily to be the same suit. For example, a hand containing 7 club, 6 spade, 5 spade, 4 heart and 3 diamond forms a straight. In this problem, we extend the definition…
题意:给你n个高度,再给你1~n每种高度的数量,已知高度连续的3~5个能消去,问你所给的情况能否全部消去:例:n = 4,给出序列1 2 2 1表示高度1的1个,高度2的2个,高度3的2个,高度4的1个.那么我打出1 1 1(高度1 2 3),1 1 1(高度2 3 4)刚好打完. 思路:对于差分数组我们知道,如果我们对区间L,R加1,那么d[L] += 1, d[R + 1] -= 1,我们可以想象这个序列是由0序列不断进行区间+1操作得到.我们打出差分数组,从左到右遍历,如果遇到正数,那么我…
题目链接:http://codeforces.com/gym/101775/problem/J 思路:序列差分一下,然后用得到的查分序列乱搞就可以了 注意差分序列第一项等于a[i],之后n-1项为cha[i]=a[i]-a[i-1],第n+1项为0-a[n] #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ; const int inf=0x3f3f3f3f; ; const double pi=acos…
题意:给出N种类的数量,求是否可以把N种牌按3-5张连续的顺子打出,顺子必须连续. 分析:相当于把这个序列分成若干长度为[3,5]的区间,当然其实分成若干段大于3的区间即可.因为大于5的区间又可以分拆成若干段长度为[3,5]的区间. 令\(b[i] = a[i] - a[i-1]\), 则\(b[i] >0\) 表示有\(b[i]\)段区间以此为起点, \(b[i] < 0\)表示有\(|b[i]|\)段区间以\(i-1\)为终点. 那么对于每个区间的起点i,必须在i+3开始的位置一直向后寻找…
比赛链接:传送门 Gym 101775A Chat Group(签到:待补) Gym 101775B Scapegoat(待补) Gym 101775C Traffic Light(贪心+思维) 思路: 需要证明两个点: ① 所有的N+1个S都是必须要走的,并且可以适当安排使得红灯只用等最长的一个. ② 上面这样的安排的答案是S0+S1+…+SN+max(Bi),而答案不可能比这个小,因为总有一种走法可以等到最长的那个红绿灯,如果其他的红绿灯也要等的话就比上面的方法大了. #include <b…
A:Chat Group 题意:给出一个n, k 计算C(n, k) -> C(n,n) 的和 思路:k只有1e5 反过来想,用总的(2^ n) 减去 C(n, 0) -> C(n, k - 1), 预处理逆元, #include <bits/stdc++.h> using namespace std; #define ll long long #define N 100010 ; int t; ll n, k; ll inv[N]; inline void Init() { in…
感觉全是思维乱搞题. Gym - 101775J Straight Master 给你n种扑克,你每次可以出连续的3 ~ 5 张,问你能否出完. Sample Input 2 13 1 2 2 1 0 0 0 0 0 0 0 0 0 13 1 1 1 1 0 1 1 0 0 0 0 0 0 Sample Output Case #1: Yes Case #2: No 相当于每次把一个长度为3~5的区间整体减1,问最后是否能够全部减成0. 显然,每次把一个长度大于5的区间整体减1也是可以的,因为6…
传送门 A.^&^ 题意: 找到最小的正数\(C\),满足\((A\ xor\ C)\&(B\ xor \ C)\)最小. 思路: 输出\(A\&B\)即可,特判答案为0的情况. Code #include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef double db; const int MAXN = 1e5+5,MAXM = 2e5+5,MOD = 1e9…
传送门 •参考资料 [1]:2019CCPC网络选拔赛 H.Fishing Master(思维+贪心) •题意 池塘里有 n 条鱼,捕捉一条鱼需要花费固定的 k 时间: 你有一个锅,每次只能煮一条鱼,其中煮熟第 i 条鱼至少需要 ti 时间: 你在煮鱼的时候可以选择去钓一条鱼,也可也选择不钓: 但是,一旦你决定钓鱼,就必须花费 k 时间调到一条鱼: 任何时刻,你都可以有多条鱼待煮: 问将所有的鱼钓上来并煮熟所有的鱼最少需要多少时间: •题解 理想的方案是只有在钓第一条鱼的时候锅是空的,其余任意时…
题意分析 题意:题目给出n条鱼,以及捕一条鱼所用的时间k,并给出煮每一条鱼的时间,问抓完并煮完所有鱼的最短时间. 附题目链接 思路: 1.捕第一条鱼的时间是不可避免的,煮每条鱼的时间也是不可避免的,这些都要算上. 2.可以优化的是煮鱼的时间,在时间允许的范围内可进行捕其他鱼.当然煮鱼的时间也许不够捕其他鱼,这就需要增加额外的时间. 3.设在煮每条鱼煮的时间内抓的最多的鱼数为cnt,捕鱼的时间为cost,将每次额外增加的时间存储在一个数组中,记为fre[ ]. 4.更多详细信息在代码中给出. AC…
题目网站:http://acm.hdu.edu.cn/showproblem.php?pid=6709 Problem Description Heard that eom is a fishing MASTER, you want to acknowledge him as your mentor. As everybody knows, if you want to be a MASTER’s apprentice, you should pass the trial. So when yo…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6709 Fishing Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 631    Accepted Submission(s): 170 Problem Description Heard that eom is a fishin…
/* 暴力枚举两个后缀,计算最长能匹配多少前缀. 最优策略一定是贪心改掉前 k 个失配的字符. 时间复杂度 O(n3). */ #include<cstdio> ],b[]; int main(){ freopen("master.in","r",stdin);freopen("master.out","w",stdout); scanf(,b+); ;i<=n;i++);j<=n;j++) ;x<…
A. The New Year: Meeting Friends time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, t…
A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of…
Shopping 题目连接: http://codeforces.com/gym/100803/attachments Description Your friend will enjoy shopping. She will walk through a mall along a straight street, where N individual shops (numbered from 1 to N) are aligned at regular intervals. Each shop…
F. Doomsday Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/F Description Doomsday comes in t units of time. In anticipation of such a significant event n people prepared m vaults in which, as they think, it will…
When the brake fluid level drops too low in the master cylinder reservoir, air bubbles can get caught in the lines, reducing the overall strength of the brake fluid column. Getting the air out of the brake fluid column will restore the full strength…
Beijing was once surrounded by four rings of city walls: the Forbidden City Wall, the Imperial City Wall, the Inner City Wall, and finally the Outer City Wall. Most of these walls were demolished in the 50s and 60s to make way for roads. The walls we…
Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, s…
Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42925   Accepted: 9485 Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locat…
Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 115873   Accepted: 25574 Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point loc…
POJ 1328 Radar Installation https://vjudge.net/problem/POJ-1328 题目: Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation…
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebo…
Problem B. Travelling Camera Problem 题目连接: http://www.codeforces.com/gym/100253 Description Programming competitions become very popular in Berland. Now Berland Broadcasting Corporation (BBC) plans to organize a TV broadcast of the All-Berland Region…
一.题目 Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distan…
http://codeforces.com/problemset/problem/555/B B. Case of Fugitive time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Andrewid the Android is a galaxy-famous detective. He is now chasing a cr…
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…
Problem A - No Tipping As Archimedes famously observed, if you put an object on a lever arm, it will exert a twisting force around the lever's fulcrum. This twisting is called torque and is equal to the object's weight multiplied by its distance from…
http://www.lydsy.com/JudgeOnline/problem.php?id=1650 看到数据和最小最大时一眼就是二分... 但是仔细想想好像判断时不能贪心? 然后看题解还真是贪心..囧. 原来是之前我脑残了. ... 贪心很简单 排序后. 当前点到之前的点的距离<m就累计(相当于删掉这个点,为什么呢?因为这个点假设last到的不是0,那么这个点删了后,因为后边的点的距离大于它,假设后边的点距离减去这个点的距离也是<m,那么显然删去这个点可以得到2个不用删去的点(否则一定要…