
CodeForces
文章平均质量分 92
CodeForces
Tisfy
LetMeFly
展开
-
LeetCode 0714. 买卖股票的最佳时机含手续费
LeetCode 0714. 买卖股票的最佳时机含手续费给定一个整数数组 prices,其中 prices[i]表示第 i 天的股票价格 ;整数 fee 代表了交易股票的手续费用。你可以无限次地完成交易,但是你每笔交易都需要付手续费。如果你已经购买了一个股票,在卖出它之前你就不能再继续购买股票了。返回获得利润的最大值。注意:这里的一笔交易指买入持有并卖出股票的整个过程,每笔交易你只需要为支付一次手续费。原创 2023-10-06 12:21:51 · 166 阅读 · 0 评论 -
LeetCode 2251. 花期内花的数目:排序 + 二分
LeetCode 2251. 花期内花的数目:排序 + 二分给你一个下标从 0 开始的二维整数数组 flowers ,其中 flowers[i] = [starti, endi] 表示第 i 朵花的 花期 从 starti 到 endi (都 包含)。同时给你一个下标从 0 开始大小为 n 的整数数组 people ,people[i] 是第 i 个人来看花的时间。请你返回一个大小为 n 的整数数组 answer ,其中 answer[i]是第 i 个人到达时在花期内花的 数目 。原创 2023-09-28 11:10:35 · 651 阅读 · 0 评论 -
LeetCode 1333. 餐厅过滤器
LeetCode 1333. 餐厅过滤器给你一个餐馆信息数组 restaurants,其中 restaurants[i] = [idi, ratingi, veganFriendlyi, pricei, distancei]。你必须使用以下三个过滤器来过滤这些餐馆信息。其中素食者友好过滤器 veganFriendly 的值可以为 true 或者 false,如果为 true 就意味着你应该只包括 veganFriendlyi 为 true 的餐馆,为 false 则意味着可以包括任何餐馆。此外,我们原创 2023-09-27 19:14:58 · 189 阅读 · 0 评论 -
LeetCode 2582. 递枕头:清晰的话讲述 O(1)的时间算法
LeetCode 2582. 递枕头:清晰的话讲述 O(1)的时间算法n 个人站成一排,按从 1 到 n 编号。最初,排在队首的第一个人拿着一个枕头。每秒钟,拿着枕头的人会将枕头传递给队伍中的下一个人。一旦枕头到达队首或队尾,传递方向就会改变,队伍会继续沿相反方向传递枕头。例如,当枕头到达第 n 个人时,TA 会将枕头传递给第 n - 1 个人,然后传递给第 n - 2 个人,依此类推。给你两个正整数 n 和 time ,返回 time 秒后拿着枕头的人的编号。原创 2023-09-26 09:02:07 · 219 阅读 · 0 评论 -
Codeforces Round 857 (Div. 2) - B. Settlement of Guinea Pigs - 题解
Codeforces Round 857 (Div. 2) - B. Settlement of Guinea Pigs - 题解Dasha loves guinea pigs very much. In this regard, she decided to settle as many guinea pigs at home as possible and developed a plan for the next n days. Every day, she will either buy a n原创 2023-04-05 22:20:28 · 584 阅读 · 0 评论 -
Codeforces Round #775 (Div. 2,based on Moscow Open Olympiad in Informatics) - D. Integral Array - 题解
Codeforces Round #775 (Div. 2,based on Moscow Open Olympiad in Informatics) - D. Integral Array - 题解You are given an array a of n positive integers numbered from 1 to n. Let's call an array integral if for any two, not necessarily different, numbers x and原创 2022-03-07 22:14:13 · 390 阅读 · 2 评论 -
Codeforces Round #750 (Div. 2) - B. Luntik and Subsequences - 题解
Codeforces Round #750 (Div. 2) - B. Luntik and Subsequences - 题解Luntik came out for a morning stroll and found an array a of length n. He calculated the sum s of the elements of the array (s=∑ni=1ai). Luntik calls a subsequence of the array a nearly full原创 2021-10-24 20:37:01 · 2147 阅读 · 0 评论 -
CodeforcesRound#749(Div.1.2basedonTechnocup2022EliminationRound1)-D.Omkar and the Meaning of Life-题解
题解 - 正好5000字Codeforces Round #749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1)D. Omkar and the Meaning of LifeIt turns out that the meaning of life原创 2021-10-19 00:09:20 · 382 阅读 · 0 评论 -
CodeforcesRound#749(Div.1+Div.2,basedonTechnocup2022EliminationRound1)-C. Omkar and Determination-题解
万字长文(5731)Codeforces Round #749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1)C. Omkar and DeterminationThe problem statement looms below, filling you with determination.Consider a grid in which some cells are empty and some cells are原创 2021-10-18 23:31:38 · 373 阅读 · 0 评论 -
CodeforcesRound#749(Div.1+Div.2,basedonTechnocup2022EliminationRound1)-B. Omkar and Heavenly Tree-题解
Codeforces Round #749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1)B. Omkar and Heavenly TreeLord Omkar would like to have a tree with n nodes (3≤n≤105) and has asked his disciples to construct the tree. However, Lord Omkar has created m原创 2021-10-18 22:19:57 · 441 阅读 · 0 评论 -
Codeforces Round #749(Div. 1+Div. 2, based on Technocup 2022 Elimination Round1)-A. Windblume Ode-题解
Codeforces Round #749(Div. 1+Div. 2, based on Technocup 2022 Elimination Round1)-A. Windblume Ode-题解Codeforces Round #749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1)A. Windblume OdeA bow adorned with nameless flowers that bears the ea原创 2021-10-18 21:45:27 · 413 阅读 · 0 评论 -
Educational Codeforces Round 112 (Rated for Div. 2)-D. Say No to Palindromes-题解
Educational Codeforces Round 112 (Rated for Div. 2)-D. Say No to Palindromes-题解Let's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way fro原创 2021-07-31 11:29:26 · 357 阅读 · 0 评论 -
Educational Codeforces Round 112 (Rated for Div. 2)-C. Coin Rows-题解
Educational Codeforces Round 112 (Rated for Div. 2)-C. Coin Rows-题解Alice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains ai,j coins in it.Initially, both Alice and Bob are原创 2021-07-31 11:13:27 · 406 阅读 · 0 评论 -
Educational Codeforces Round 112 (Rated for Div. 2)-B. Two Tables-题解
Educational Codeforces Round 112 (Rated for Div. 2)-B. Two Tables-题解You have an axis-aligned rectangle room with width W and height H, so the lower left corner is in point (0,0) and the upper right corner is in (W,H).There is a rectangular table standin原创 2021-07-31 10:56:07 · 328 阅读 · 0 评论 -
Educational Codeforces Round 112 (Rated for Div. 2)-A. PizzaForces-题解
Educational Codeforces Round 112 (Rated for Div. 2)-A. PizzaForces-题解PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of 6 slices, medium ones consist of 8 slices, and large pizzas consist o原创 2021-07-31 10:36:20 · 427 阅读 · 0 评论 -
Codeforces Round #735 (Div. 2)-C. Mikasa-题解
Codeforces Round #735 (Div. 2)-C. Mikasa-题解You are given two integers n and m. Find the MEX of the sequence n⊕0,n⊕1,…,n⊕m. Here, ⊕ is the bitwise XOR operator.MEX of the sequence of non-negative integers is the smallest non-negative integer that doesn't原创 2021-07-30 11:37:55 · 682 阅读 · 3 评论 -
Codeforces Round #735 (Div. 2)-B. Cobb-题解
Codeforces Round #735 (Div. 2)-A. Cherry-题解You are given n integers a1,a2,…,an and an integer k. Find the maximum value of i⋅j−k⋅(ai|aj) over all pairs (i,j) of integers with 1≤i<j≤n. Here, | is the bitwise OR operator.InputThe first line contains a si原创 2021-07-30 11:13:12 · 814 阅读 · 2 评论 -
Codeforces Round #735 (Div. 2)-A. Cherry-题解
Codeforces Round #735 (Div. 2)-A. Cherry-题解You are given n integers a1,a2,…,an. Find the maximum value of max(al,al+1,…,ar)⋅min(al,al+1,…,ar) over all pairs (l,r) of integers for which 1≤l<r≤n.InputThe first line contains a single integer t (1≤t≤10000)原创 2021-07-30 10:53:02 · 364 阅读 · 2 评论 -
Codeforces Round #734 (Div. 3)-D2. Domino (hard version)-题解
Codeforces Round #734 (Div. 3)-D2. Domino (hard version)The only difference between this problem and D1 is that you don't have to provide the wayThere's a table of $n \times m$ cells ($n$ rows and $m$ columns). The value of $n \cdot m$ is even.原创 2021-07-24 23:24:42 · 436 阅读 · 4 评论 -
Codeforces Round #734 (Div. 3)-D1. Domino (easy version)-题解
Codeforces Round #734 (Div. 3)-D1. Domino (easy version)-题解Polycarp must pay **exactly** $n$ burles at the checkout. He has coins of two nominal values: $1$ burle and $2$ burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with m原创 2021-07-24 23:01:15 · 656 阅读 · 2 评论 -
Codeforces Round #734 (Div. 3)-C. Interesting Story-题解
目录Codeforces Round #734 (Div. 3)-C. Interesting StoryProblem DescriptionInputOutputSample InputSample OnputNote题目大意解题思路AC代码Codeforces Round #734 (Div. 3)-C. Interesting Story传送门Time Limit: 4 secondsMemory Limit: 256 megabytesProblem DescriptionSteph.原创 2021-07-24 22:34:58 · 553 阅读 · 0 评论 -
Codeforces Round #734 (Div. 3)-B2. Wonderful Coloring - 2-题解
Codeforces Round #734 (Div. 3)-B2. Wonderful Coloring - 2-题解Polycarp must pay **exactly** $n$ burles at the checkout. He has coins of two nominal values: $1$ burle and $2$ burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with原创 2021-07-24 22:12:19 · 569 阅读 · 0 评论 -
Codeforces Round #734 (Div. 3)-B1. Wonderful Coloring - 1
Codeforces Round #734 (Div. 3)-B1. Wonderful Coloring - 1**This is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.**Paul and Mary have a favorite string $s$ which consists of lowercase letters o原创 2021-07-24 21:59:03 · 476 阅读 · 0 评论 -
Codeforces Round #734 (Div. 3)-A. Polycarp and Coins-题解
Codeforces Round #734 (Div. 3)-A. Polycarp and Coins-题解<a href="https://codeforces.com/contest/1551/problem/A">传送门</a>**Time Limit**: 1 second**Memory Limit**: 256 megabytes### Problem DescriptionPolycarp must pay **exactly** $n$ burles at the check原创 2021-07-24 21:46:11 · 455 阅读 · 2 评论 -
Codeforces Round #717 (Div. 2)-A. Find The Array-题解
Codeforces Round #717 (Div. 2)-B. Maximum Cost Deletion-题解Let's call an array a consisting of n positive (greater than 0) integers beautiful if the following condition is held for every i from 1 to n: either ai=1, or at least one of the numbers ai−1 and a原创 2021-07-16 00:15:22 · 358 阅读 · 0 评论 -
Codeforces Round #717 (Div. 2)-B. Maximum Cost Deletion-题解
Codeforces Round #717 (Div. 2)-B. Maximum Cost Deletion-题解You are given a string s of length n consisting only of the characters 0 and 1.You perform the following operation until the string becomes empty: choose some consecutive substring of equal chara原创 2021-07-16 00:02:39 · 492 阅读 · 4 评论 -
Codeforces Round #717 (Div. 2)-C. Baby Ehab Partitions Again-题解
Codeforces Round #717 (Div. 2)-C. Baby Ehab Partitions Again-题解Suppose you have two points p=(xp,yp) and q=(xq,yq). Let's denote the Manhattan distance between them as d(p,q)=|xp−xq|+|yp−yq|.Let's say that three points p, q, r f原创 2021-07-15 23:28:48 · 339 阅读 · 0 评论 -
Codeforces Round #717 (Div. 2)-C. Baby Ehab Partitions Again-题解
目录Codeforces Round #717 (Div. 2)-C. Baby Ehab Partitions AgainProblem DescriptionInputOutputSample InputSample OnputNote题目大意输出描述解题思路AC代码Codeforces Round #717 (Div. 2)-C. Baby Ehab Partitions Again传送门Time Limit: 2 secondsMemory Limit: 256 megabytesProb原创 2021-05-02 17:45:11 · 1547 阅读 · 10 评论 -
Codeforces Round #717 (Div. 2)-B. AGAGA XOOORRR-题解
目录Codeforces Round #717 (Div. 2)-B. AGAGA XOOORRRProblem DescriptionInputOutputSample InputSample OnputNote题目大意解题思路AC代码Codeforces Round #717 (Div. 2)-B. AGAGA XOOORRR传送门Time Limit: 1 secondMemory Limit: 256 megabytesProblem DescriptionBaby Ehab is kn原创 2021-05-02 17:15:10 · 1729 阅读 · 6 评论 -
Codeforces Round #717 (Div. 2)-A. Tit for Tat-题解
目录Codeforces Round #717 (Div. 2)-A. Tit for TatProblem DescriptionInputOutputSample InputSample OnputNote题目大意题目分析AC代码Codeforces Round #717 (Div. 2)-A. Tit for Tat传送门Time Limit: 1 secondMemory Limit: 256 megabytesProblem DescriptionGiven an array aaa原创 2021-05-02 16:12:23 · 1483 阅读 · 4 评论 -
Educational Codeforces Round 108 (Rated for Div. 2)-D. Maximum Sum of Products-题解
目录Educational Codeforces Round 108 (Rated for Div. 2)-D. Maximum Sum of ProductsProblem DescriptionInputOutputSample InputSample OnputNote题目大意解题思路AC代码Educational Codeforces Round 108 (Rated for Div. 2)-D. Maximum Sum of Products传送门Time Limit: 2 seconds原创 2021-05-01 22:59:13 · 2000 阅读 · 8 评论 -
Educational Codeforces Round 108 (Rated for Div. 2)-C. Berland Regional-题解
目录Educational Codeforces Round 108 (Rated for Div. 2)-C. Berland RegionalProblem DescriptionInputOutputSample InputSample OnputNote题目大意输入描述题目分析AC代码Educational Codeforces Round 108 (Rated for Div. 2)-C. Berland Regional传送门Time Limit: 2 secondsMemory Lim原创 2021-05-01 17:27:54 · 1898 阅读 · 4 评论 -
Educational Codeforces Round 108 (Rated for Div. 2)-B. The Cake Is a Lie-题解
目录Educational Codeforces Round 108 (Rated for Div. 2)-B. The Cake Is a LieProblem DescriptionInputOutputSample InputSample OnputNote题目大意解题思路AC代码Educational Codeforces Round 108 (Rated for Div. 2)-B. The Cake Is a Lie传送门Time Limit: 2 secondsMemory Limit原创 2021-05-01 16:21:59 · 1828 阅读 · 10 评论 -
Educational Codeforces Round 108 (Rated for Div. 2)-A. Red and Blue Beans-题解
目录Educational Codeforces Round 108 (Rated for Div. 2)-A. Red and Blue BeansProblem DescriptionInputOutputSample InputSample OnputNote题目大意解题思路AC代码Educational Codeforces Round 108 (Rated for Div. 2)-A. Red and Blue Beans传送门Time Limit: 1 secondMemory Limi原创 2021-05-01 15:56:38 · 1917 阅读 · 4 评论 -
Codeforces Round #713 (Div. 3)-E. Permutation by Sum-题解
目录Codeforces Round #713 (Div. 3)-E. Permutation by SumProblem DescriptionInputOutputSample InputSample Onput题目大意解题思路AC代码Codeforces Round #713 (Div. 3)-E. Permutation by Sum传送门Time Limit: 2 secondsMemory Limit: 256 megabytesProblem DescriptionA permut原创 2021-04-11 15:05:18 · 10107 阅读 · 32 评论 -
Codeforces Round #713 (Div. 3)-D. Corrupted Array-题解
目录Codeforces Round #713 (Div. 3)-D. Corrupted ArrayProblem DescriptionInputOutputSample InputSample Onput题目大意解题思路例如AC代码Codeforces Round #713 (Div. 3)-D. Corrupted Array传送门Time Limit: 2 secondsMemory Limit: 256 megabytesProblem DescriptionYou are give原创 2021-04-11 14:46:59 · 9988 阅读 · 10 评论 -
Codeforces Round #713 (Div. 3)-C. A-B Palindrome-题解
目录Codeforces Round #713 (Div. 3)-C. A-B PalindromeProblem DescriptionInputOutputSample InputSample Onput题目大意解题思路AC代码Codeforces Round #713 (Div. 3)-C. A-B Palindrome传送门Time Limit: 2 secondsMemory Limit: 256 megabytesProblem DescriptionYou are given a原创 2021-04-11 14:32:34 · 10156 阅读 · 8 评论 -
Codeforces Round #713 (Div. 3)-B. Almost Rectangle-题解
目录Codeforces Round #713 (Div. 3)-B. Almost RectangleProblem DescriptionInputOutputSample InputSample Onput题目大意解题思路AC代码Codeforces Round #713 (Div. 3)-B. Almost Rectangle传送门Time Limit: 2 secondsMemory Limit: 256 megabytesProblem DescriptionThere is a s原创 2021-04-11 13:37:28 · 10037 阅读 · 4 评论 -
Codeforces Round #713 (Div. 3)-A. Spy Detected!-题解
目录Codeforces Round #713 (Div. 3)-A. Spy Detected!Problem DescriptionInputOutputSample InputSample Onput题目大意解题思路AC代码Codeforces Round #713 (Div. 3)-A. Spy Detected!传送门Time Limit: 2 secondsMemory Limit: 256 megabytesProblem DescriptionYou are given an a原创 2021-04-11 13:21:42 · 9917 阅读 · 5 评论 -
Codeforces April Fools Day Contest 2021-B. DMCA-题解
目录Codeforces April Fools Day Contest 2021-B. DMCAInputOutputExampleInputOutPutInputOutPut题目大意题解另外样例分析AC代码Codeforces April Fools Day Contest 2021-B. DMCA传送门Time Limit: 1 secondsMemory Limit: 256 megabytesMany people are aware of DMCA – Digital Millenni原创 2021-04-03 15:52:13 · 10330 阅读 · 6 评论