自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(31)
  • 收藏
  • 关注

原创 CODEFORES Day28(dp)

题目:最大子序列和题意:给定一个整数数组nums,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。示例:输入:[-2,1,-3,4,-1,2,1,-5,4],输出:6解释:连续子数组[4,-1,2,1] 的和最大,为6#include <iostream>#include<algorithm>#include<string>#include<map>#include<cmath>#...

2021-08-22 20:34:46 87

原创 CODEOFORCES Day27(hash)

题目:D. Same Differences链接:link思路:aj-ai=j-i->aj-j=ai-i#include <iostream>#include<algorithm>#include<string>#include<map>#define ll long longusing namespace std;const int N=101;int dp[N];int nums[N];map<int, ll

2021-08-19 21:18:15 84

原创 CODEFORCES Day26(binary search)

题目:B. Interesting drink题目大意:有n家超市卖这种饮料,每家卖的价格不同,主人公要买q天 ,每天都有钱m[i]问最多能有几家商店是可以买得起的思路:元素查找,比较每天零花钱的价格与售卖饮料的价格->如果大于ans++;#include <iostream>#include<algorithm>#include<string>using namespace std;const int N=100001;int a[N]

2021-08-17 20:52:49 175

原创 CODEFORCES Day26

题目:B. Young Explorers链接:link题目大意:一群人去探险,每个人都有对应的经验值,经验值用来分组,例如经验值为1的人要去人数大于等于1的小组,问最多能分多少组思路:贪心策略,排序,按照从小到大排,先让经验值少的人组队。#include <iostream>#include<string>#include<algorithm>#define ll long longusing namespace std;const in

2021-08-16 20:40:04 114

原创 CODEFORCES Day25

题目:C. Alternating Subsequence思路:双指针,找正数找大的,负数找大的#include<iostream>#include<string>#include<vector>#include<algorithm>#include<map>#include<cstring>#include<cmath>#define ll long longusing namespace s

2021-08-15 21:14:32 73

原创 CODEFORCES Day24(dp入门)

题目:A. Cut Ribbon????:link思路:第一步:定义一个一维数组dp[i],表示段数为i的时候最后可以由多少段组成,那么dp[n]就是答案第二步:状态转移方程(注意最后一步)dp[i]=max(dp[i],dp[i-x]+1)第三步:边界问题,memset(dp, -1, sizeof(dp));,初始化dp[0]=0;#include<iostream>#include<string>#include<vector>#

2021-08-13 22:02:48 186

原创 CODEFORCES Day23

题目:B. Pashmak and Flowers链接????:link思路:将容器排序,求极差,再利用二分查找,统计最小值和最大值的个数,相乘就是答案(特殊情况,当极差等于0的时候,ans=n*(n-1)/2)#include<iostream>#include<string>#include<vector>#include<algorithm>#include<map>using namespace std;#

2021-08-11 17:45:41 75

原创 CODEFORCES Day22(implementation)

题目:A. Cheap Travel????link思路:n个站点,普通票,只能坐一站a元,特殊票可以坐m站b元,问怎么花最少四种情况:1)全买普通票2)全买特殊票3)组合着买核心代码:min(ans1,min(ans2,ans3));解:#include<iostream>#include<string>#include<vector>#include<algorithm>#include<map&gt

2021-08-08 18:09:24 113

原创 CODEFOERCES DAY21

题目:B. TERNARY STRING链接????:https://codeforces.com/problemset/problem/1354/B题目意思:一个字符串,只由1,2,3构成,找1,2,3连续出现的最短子串。思路:

2021-08-07 20:04:15 68

原创 CODEFORCES Day20

题目:C. Coin Rows链接link思路:因为只能够向下或者向右移动,那么只需要找第一行的后缀与第二行的前缀,比较前缀后缀的大小。#include <iostream>#include<vector>#include<math.h>#include<cmath>using namespace std;const int maxn=100000;int a[2][maxn];int t;int main(int argc

2021-08-05 21:19:03 72

原创 CODEFORCES Day19

题目:B. Pleasant Pairs链接:link题意:一个数组,每个数都不相同,找到数组中满足(下标之和=对应元素相乘)i+j=ai*aj(i<j)思路:

2021-08-04 16:38:16 77

原创 CODEFORCES Day 18

题目:Two TableB. Two Tablestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an axis-aligned rectangle room with width????Wand height????H, so the lower left corner is in point(

2021-08-03 21:28:55 70

原创 CODEFORCES Day17

题目:B. Sort the ArrayBeing a programmer, you like arrays a lot. For your birthday, your friends have given you an arrayaconsisting ofndistinctintegers.Unfortunately, the size ofais too small. You want a bigger array! Your friends agree to give ...

2021-08-02 20:46:52 67

原创 Codeforces Round #736 (Div. 2)

玩了一天,一回家还没坐下多久就开始了。太累了,但还是强迫自己写了点第一题:题目链接:https://m1.codeforces.com/contest/1549/problem/A题目:给你一个素数,求从2到p之间的两个值使得????mod????=????mod????。思路:因为是素数,所以这个数一定是奇数(不是说奇数都是素数的意思,但是素数除了2一定是奇数)。直接找p mod a=1的情况那么a=2,b=p-1;直接输出就行了。代码段明天再补上第二题:题目链接B

2021-08-02 00:59:19 83

原创 CODEFORCES Day 16

题目:C. Penaltytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a simplified penalty phase at the end of a football match.A penalty phase consists of at most1010kicks, the ..

2021-07-31 21:29:24 97

原创 CODEFORCES Day15

题目:C. Registration systemtime limit per test5 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputA new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration

2021-07-30 20:30:58 108

原创 CODEFORCES Day14

题目:A. Winnertime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputThe winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of

2021-07-29 17:57:58 58

原创 CODEFORCES Day13

题目:B. Anton and currency you all knowtime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland, 2016. The exchange rate ofcurrency you all knowagainst the burle has increased so mu..

2021-07-28 16:46:54 126

原创 CODEFORCES Day12

题目:A. BerOS file system题意:出现多个‘/’的时候,只留下一个‘/’,考察字符串的删除#include <iostream>#include<algorithm>#include<string>#include<vector>#define LL long longusing namespace std;string s;void solve(string &s){ string::itera

2021-07-27 19:27:23 71

原创 CODEFORCES Day11

题目:A. Minimizing the String给一个字符串,只能对其删除最多一个字符,问怎么删除才能使得这个字符串变得最小?思路:字符串的比较,越处于前面的字符越能决定字符串的大小,所以从前面的字符开始依次与其后面一位字符比较,如果后一位字符更小则删除当前字符。#include<bits/stdc++.h>#define LL long longusing namespace std;const int N=100;int n;string s;char c

2021-07-26 20:55:40 67

原创 CODEFORCES Day10

题目:Email from Polycarp题意:小明的键盘坏了,按一次键可能会重复输入,有n组案例,每组案例有一对字符串,第一对字符串使用好的键盘输入的,第二个键盘是用小明的坏的键盘输入的,判断第二个键盘原本想输入的单词是不是和第一个键盘输入的一样思路:两个字符串一个一个位置的比较,如果是一样的字符的活就比较下一位,不一样的话有两种情况:1)可能是有重复的,那就跳过重复的,继续比较 2)出现了第一个字符串中没有出现过的字符,这种情况直接return false;...

2021-07-25 17:43:04 89

原创 codeforces day 9 IQ TEST

题意:题意就是给你一串数字,这一串数字里只有一个数字的奇偶性与其他的数字的不同,输出他所在的位置思路:奇数多找偶数,偶数多找奇数#include<bits/stdc++.h>#define LL long longusing namespace std;const int N=100;int arry[N];int main(){ //题意就是给你一串数字,这一串数字里只有一个数字的奇偶性与其他的数字的不同,输出他所在的位置 int n,flag1=0,fl

2021-07-24 16:31:25 76

原创 codeforces day8 accuratelee

题意:有一个由‘0’和‘1’组成的字符串,‘10’结构可以删除1或者删去0,给你一个这样的字符串问最短的字符串是怎么样的并输出思路:规律,找第一个出现的1和最后一个出现的0,可以通过find函数来找1返回第一个1出现的额位置,用rfind函数来找0,返回最后一个0的位置,如果找不到1或0的话说明现在的这个字符串就是最简洁的,拷贝给目标字符串输出就可以,如果找到了且first<last,将first之前的字符拷贝给目标字符串,以及last及其之后的字符拷贝给目标字符串并输出...

2021-07-23 19:48:53 87

原创 code forces day 7

题意:学校要举办一个舞会,每个人都要有自己的舞伴,要当对方舞伴的条件是会的舞蹈数量与对方会的舞蹈的数量相差不超过一个,有n个男生会的舞种已知,有m个女生会的舞种已知,问最多有多少对#include <iostream>#include<algorithm>#include<cstring>using namespace std;int a[100];int b[100];int test01(int a[],int n,int x){ //举例

2021-07-22 15:45:27 127

原创 算法:二分查找

#include <iostream>using namespace std;//二分查找的基本应用场景->查找序列中是否有存在符合条件的元素,二分查找是基于有序数列的一种算法int a[100];//lower_bound,它寻找的就是第一个满足条件值“大于等于x”的元素的位置;//upper_bound,它寻找的是第一个满足条件“值大于x”的元素的位置//这两个函数有四个参数,第一个参数是第一个元素地址,第二个参数是要查找范围的最后一个元素地址,第三个参数是要找的数字,第四.

2021-07-22 14:02:12 62

原创 codeforces day 6 Balance Team

problems tag:sort,two pointers题意:大概就是有n个学生要参加比赛,当然参加比赛的人越多获奖的机会越高,但是一个团队需要平衡,不能一些学生什么都会,一些学生什么都不会,所以我们应该尽量选择一个平衡的团队,每个人会的技能都小于等于5个那么我们就说这个团队是平衡的,输出这个团队最多能有多少个人。思路:这道题思路其实很简单,就是团队里的每个人之间相差不大于5。我一开始的想法就是很简单粗暴,将数组按照从小到大的顺序进行排列,计算每个数字最多有几个相差不大于5的数字,并更新ans,

2021-07-21 15:38:29 101

原创 codeforces day 5

problem tags:greedy,implementions题目:有一只鲨鱼,它有几排牙齿,吃罗非鱼为生,吃一只罗非鱼用一排牙齿,每排牙齿都有忍耐度,当忍耐度不可为负数input: the first lines is 3 integers n,m,k(1 ≤ m ≤ n ≤ 1000, 0 ≤ k ≤ 106) ,.--total amount of Valerie's teeth, amount of tooth rows and amount of crucians in Valeri.

2021-07-19 17:03:55 69

原创 codeforces day 4

problem tags:greedy,brute force题目:C. Boats Competitiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are????npeople who want to participate in a boat competition. The weight

2021-07-19 12:57:12 55

原创 codeforces day 3 Cat Cycle

题目:B. Cat Cycletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSuppose you are living with two cats: A and B. There are????nnapping spots where both cats usually sleep.Your cats lik

2021-07-18 15:14:33 205

原创 codeforces day2 1409c

题目:C. Yet Another Array Restorationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe have a secret array. You don't know this array and you have to restore it. However, you know some

2021-07-17 15:16:52 103

原创 codeforces day1 33A worms evolution

#include<iostream>#include<algorithm>using namespace std;int main(){ int n; int a[1000]; cin>>n; if (n>=3&&n<=100) { for (int x=1; x<=n; x++) { cin>&g...

2021-07-16 17:56:42 291

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除