贪心
文章平均质量分 59
旺 崽
这个作者很懒,什么都没留下…
展开
-
LeetCode 781 森林中的兔子
题目链接森林中,每个兔子都有颜色。其中一些兔子(可能是全部)告诉你还有多少其他的兔子和自己有相同的颜色。我们将这些回答放在 answers 数组里。返回森林中兔子的最少数量。示例:输入: answers = [1, 1, 2]输出: 5解释:两只回答了 "1" 的兔子可能有相同的颜色,设为红色。之后回答了 "2" 的兔子不会是红色,否则他们的回答会相互矛盾。设回答了 "2" 的兔子为蓝色。此外,森林中还应有另外 2 只蓝色兔子的回答没有包含在数组中。因此森林中兔子的最少数量是 5: 3原创 2021-04-04 10:32:26 · 1900 阅读 · 0 评论 -
LeetCode 5655 重新排列后的最大子矩阵
LeetCode 5655 重新排列后的最大子矩阵题目链接给你一个二进制矩阵 matrix ,它的大小为 m x n ,你可以将 matrix 中的 列 按任意顺序重新排列。请你返回最优方案下将 matrix 重新排列后,全是 1 的子矩阵面积。示例 1:输入:matrix = [[0,0,1],[1,1,1],[1,0,1]]输出:4解释:你可以按照上图方式重新排列矩阵的每一列。最大的全 1 子矩阵是上图中加粗的部分,面积为 4 。示例 2:输入:matrix = [[1,0,1原创 2021-01-17 18:39:15 · 3246 阅读 · 0 评论 -
Educational Codeforces Round 99 (Rated for Div. 2) D. Sequence and Swaps
Educational Codeforces Round 99 (Rated for Div. 2) D. Sequence and Swaps题目链接You are given a sequence a consisting of n integers a1,a2,…,an, and an integer x. Your task is to make the sequence a sorted (it is considered sorted if the condition a1≤a2≤a3≤⋯≤原创 2020-12-17 20:29:26 · 2251 阅读 · 0 评论 -
Codeforces 1250J The Parade
Codeforces 1250J The ParadeThe Berland Army is preparing for a large military parade. It is already decided that the soldiers participating in it will be divided into k rows, and all rows will contain the same number of soldiers.Of course, not every arra原创 2020-12-17 18:41:47 · 2301 阅读 · 0 评论 -
2020年广东工业大学第十届文远知行杯新生程序设计竞赛(同步赛)G.排解忧伤
2020年广东工业大学第十届文远知行杯新生程序设计竞赛(同步赛)G.排解忧伤题目链接题目描述猪猪参加小米赞助的icpc比赛之后惨遭打铁,为了排解忧伤,他开始观察嘉宾席。嘉宾席是间隔为1,一字排开的n个座椅,从左至右标号为1到n。有m个嘉宾,每个嘉宾有一个心仪座位Ai,注意,不同嘉宾的心仪座位可能相同。嘉宾们会统一从一排座位的最左侧依次入场。一个嘉宾首先会走到他心仪的位子,如果此时他发现没有人坐,他就会立刻占据这个位子。如果已经有人坐了,该嘉宾会继续向右走,直到遇到一个空位子,立刻坐下。每个嘉宾的怒气原创 2020-12-06 23:03:57 · 2513 阅读 · 0 评论 -
LeetCode 1024 视频拼接
LeetCode 1024 视频拼接题目链接你将会获得一系列视频片段,这些片段来自于一项持续时长为 T 秒的体育赛事。这些片段可能有所重叠,也可能长度不一。视频片段 clips[i] 都用区间进行表示:开始于 clips[i][0] 并于 clips[i][1] 结束。我们甚至可以对这些片段自由地再剪辑,例如片段 [0, 7] 可以剪切成 [0, 1] + [1, 3] + [3, 7] 三部分。我们需要将这些片段进行再剪辑,并将剪辑后的内容拼接成覆盖整个运动过程的片段([0, T])。返回所需片段原创 2020-10-24 20:37:59 · 8982 阅读 · 0 评论 -
LeetCode 763 划分字母区间
LeetCode 763 划分字母区间题目链接字符串 S 由小写字母组成。我们要把这个字符串划分为尽可能多的片段,同一个字母只会出现在其中的一个片段。返回一个表示每个字符串片段的长度的列表。示例 1:输入:S = "ababcbacadefegdehijhklij"输出:[9,7,8]解释:划分结果为 "ababcbaca", "defegde", "hijhklij"。每个字母最多出现在一个片段中。像 "ababcbacadefegde", "hijhklij" 的划分是错误的,因为划原创 2020-10-22 10:28:38 · 2203 阅读 · 0 评论 -
牛客小白月赛4 H.相邻的糖果
牛客小白月赛4 H.相邻的糖果题目链接题目描述有n个盒子摆成一排,每个盒子内都有ai个糖果。现在你可以执行以下操作:你可以选择任意一个盒子,在选择的盒子内吃掉一个糖果。对你的要求如下:任何m个相邻的盒子内糖果数量不能超过x个。请问,实现要求的最少操作次数是多少?输入描述:第一行三个数字n, m, x(2 ≤ n,m ≤ 1e6,1 ≤ x ≤ 1e9)。第二行n个数字(1 ≤ ai ≤ 1e9)。输出描述:输出一个操作数,代表实现要求的最少操作数。示例1输入3 2 32 1原创 2020-08-31 09:17:57 · 2415 阅读 · 0 评论 -
牛客小白月赛2 I.艺
牛客小白月赛2 I.艺题目链接题目描述接下去,Sεlιнα 又搞了个文艺竞演。虽说是文艺竞演,其实只是为了满足 Sεlιнα 的内心企盼——看群男友献歌献舞。她排列好了各个参赛男友的节目顺序,然后将他们安排在两个舞台上表演,自己则在演播室里使用两台闭路电视同时观看。万万没想到的是,当一切准备就绪时,其中一台电视炸了,她不会修,也没有时间修。于是只能尴尬地使用一台闭路电视观看两个舞台上的节目。当然,这台电视不支持分屏同时观看,所以 Sεlιнα 只能不停地换台观看。现在,作为导演的 Sεlιнα 已经原创 2020-08-14 16:57:47 · 2322 阅读 · 0 评论 -
2020牛客暑期多校训练营(第八场)K.Kabaleo Lite
2020牛客暑期多校训练营(第八场)K.Kabaleo Lite题目链接题目描述Tired of boring WFH (work from home), Apollo decided to open a fast food restaurant, called Kabaleo Lite\textbf{Kabaleo Lite}Kabaleo Lite.The restaurant serves n kinds of food, numbered from 1 to n. The原创 2020-08-04 09:54:36 · 2478 阅读 · 0 评论 -
HDUOJ 6799 Parentheses Matching
HDUOJ 6799 Parentheses Matching题目链接Problem DescriptionGiven a string P consisting of only parentheses and asterisk characters (i.e. “(”, “)” and “"), you are asked to replace all the asterisk characters in order to get a balanced parenthesis string with原创 2020-07-30 19:31:29 · 2442 阅读 · 0 评论 -
M-SOLUTIONS Programming Contest 2020 D.Road to Millionaire
M-SOLUTIONS Programming Contest 2020 D.Road to Millionaire题目链接典型的股票买卖问题,允许任意次交易就非常简单,如果前一天股票便宜就买前一天的然后今天卖出,典型的贪心策略,注意题目卡 int 了,AC代码如下:#include<bits/stdc++.h>using namespace std;typedef long long ll;int n,m; ll a[1005];int main(){ cin>原创 2020-07-26 10:44:38 · 2409 阅读 · 0 评论 -
2020牛客暑期多校训练营(第一场)H.Minimum-cost Flow
2020牛客暑期多校训练营(第一场)H.Minimum-cost Flow题目链接题目描述Bobo has a network of nn nodes and mm arcs. The iii-th arc goes from the aia_iai-th node to the bib_ibi-th node, with cost cic_ici.Bobo also asks q questions. The ii-th question is specified by two intege原创 2020-07-21 20:11:41 · 2463 阅读 · 0 评论 -
Codeforces Round #642 (Div. 3) E. K-periodic Garland
Codeforces Round #642 (Div. 3) E. K-periodic Garland题目链接You are given a garland consisting of n lamps. States of the lamps are represented by the string s of length n. The i-th character of the string si equals ‘0’ if the i-th lamp is turned off or ‘1’ i原创 2020-06-18 15:52:30 · 2318 阅读 · 0 评论 -
Codeforces Round #649 (Div. 2) B. Most socially-distanced subsequence
Codeforces Round #649 (Div. 2) B. Most socially-distanced subsequence题目链接Given a permutation p of length n, find its subsequence s1, s2, …, sk of length at least 2 such that:|s1−s2|+|s2−s3|+…+|sk−1−sk| is as big as possible over all subsequences of p wi原创 2020-06-17 15:48:25 · 2330 阅读 · 0 评论 -
Codeforces Round #643 (Div. 2) B.Young Explorers
Codeforces Round #643 (Div. 2) B.Young Explorers题目链接Young wilderness explorers set off to their first expedition led by senior explorer Russell. Explorers went into a forest, set up a camp and decided to split into groups to explore as much interesting l原创 2020-05-17 09:54:48 · 2444 阅读 · 0 评论 -
Codeforces Round #609 (Div. 1) B.Domino for Young
Codeforces Round #609 (Div. 1) B.Domino for Young题目链接You are given a Young diagram.Given diagram is a histogram with n columns of lengths a1,a2,…,an (a1≥a2≥…≥an≥1).Young diagram for a=[3,2,2,2,1]...原创 2020-04-24 17:08:39 · 2517 阅读 · 0 评论 -
牛客 14894 最长回文
牛客 14894 最长回文题目链接题目描述有两个长度均为n的字符串A和B。可以从A中选一个可以为空的子串A[l1…r1],B中选一个可以为空的子串B[l2…r2],满足r1=l2,然后把它们拼起来(A[l1…r1]+B[l2…r2])。求用这样的方法能得到的最长回文串的长度。注意:求的不是本质不同的回文串个数哦!!!输入描述:第一行一个数n第二行表示字符串A第三行表示字符串B输出描...原创 2020-04-12 16:24:42 · 2511 阅读 · 1 评论 -
Educational Codeforces Round 85 (Rated for Div. 2) C.Circle of Monsters
Educational Codeforces Round 85 (Rated for Div. 2) C.Circle of MonstersYou are playing another computer game, and now you have to slay n monsters. These monsters are standing in a circle, numbered cl...原创 2020-04-12 10:49:15 · 2393 阅读 · 0 评论 -
Educational Codeforces Round 85 (Rated for Div. 2) D.Minimum Euler Cycle
Educational Codeforces Round 85 (Rated for Div. 2) D.Minimum Euler Cycle题目链接You are given a complete directed graph Kn with n vertices: each pair of vertices u≠v in Kn have both directed edges (u,v)...原创 2020-04-12 10:35:59 · 2271 阅读 · 0 评论 -
Codeforces Round #632 (Div. 2) B.Kind Anton
Codeforces Round #632 (Div. 2) B.Kind Anton题目链接Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem:There are two arrays of integers a ...原创 2020-04-09 10:38:44 · 2247 阅读 · 0 评论 -
Codeforces Round #629 (Div. 3) C.Ternary XOR
Codeforces Round #629 (Div. 3) C.Ternary XORA number is ternary if it contains only digits 0, 1 and 2. For example, the following numbers are ternary: 1022, 11, 21, 2002.You are given a long ternary...原创 2020-03-27 08:51:13 · 2376 阅读 · 0 评论 -
AtCoder Beginner Contest 159 E.Dividing Chocolate
AtCoder Beginner Contest 159 E.Dividing Chocolate题目链接Problem StatementWe have a chocolate bar partitioned into H horizontal rows and W vertical columns of squares.The square (i,j) at the i-th row ...原创 2020-03-23 13:09:17 · 2446 阅读 · 0 评论 -
锦标赛
锦标赛题目描述组委会正在为美团点评CodeM大赛的决赛设计新赛制。比赛有 n 个人参加(其中 n 为2的幂),每个参赛者根据资格赛和预赛、复赛的成绩,会有不同的积分。比赛采取锦标赛赛制,分轮次进行,设某一轮有 m 个人参加,那么参赛者会被分为 m/2 组,每组恰好 2 人,m/2 组的人分别厮杀。我们假定积分高的人肯定获胜,若积分一样,则随机产生获胜者。获胜者获得参加下一轮的资格,输的人被淘...原创 2020-03-09 10:10:52 · 457 阅读 · 0 评论 -
团体程序设计天梯赛 L2-003 月饼
团体程序设计天梯赛 L2-003 月饼题目链接月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼。现给定所有种类月饼的库存量、总售价、以及市场的最大需求量,请你计算可以获得的最大收益是多少。注意:销售时允许取出一部分库存。样例给出的情形是这样的:假如我们有 3 种月饼,其库存量分别为 18、15、10 万吨,总售价分别为 75、72、45 亿元。如果市场的最大需求量只有 ...原创 2020-03-06 10:34:06 · 2295 阅读 · 0 评论