随笔分类 -  codeforces

上一页 1 ··· 6 7 8 9 10 11 下一页
摘要:题意: 给你 n 长全排列的一种情况,将其分为 k 份,取每份中的最大值相加,输出和的最大值和有多少种分法等于最大值。 思路: 取前 k 大值,储存下标,每两个 k 大值间有 vi+1 - vi 种分法,相乘即可。 #include <bits/stdc++.h> using namespace s 阅读全文
posted @ 2020-03-20 01:24 Kanoon 阅读(398) 评论(0) 推荐(0)
摘要:题意: 有数组 an,定义 xi 为 a 的前 i - 1 位的最大值(x0 = 0),定义 bi 为 ai - xi,给出数组 bn,还原数组 an。 思路: 因为 x0 = 0,所以 b0 = a0,之后维护最大值即可。 #include <bits/stdc++.h> using namesp 阅读全文
posted @ 2020-03-20 01:17 Kanoon 阅读(229) 评论(0) 推荐(0)
摘要:题意: 给你一个 n,输出一个 n 位不含 0 且不被任一位整除的正数。 思路: 构造 233 或 899。 #include <bits/stdc++.h> using namespace std; void solve(){ int n;cin>>n; if(n==1) cout<<"-1\n" 阅读全文
posted @ 2020-03-20 01:11 Kanoon 阅读(258) 评论(0) 推荐(0)
摘要:Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version) 题意: 你是一名建筑工程师,现给出 n 幢建筑的预计建设高度,你想建成峰状,如: 1 2 3 2 1 → 1 2 3 2 1 1 2 3 1 2 → 1 2 3 1 1 8 1 阅读全文
posted @ 2020-03-19 20:51 Kanoon 阅读(135) 评论(0) 推荐(0)
摘要:Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n 和你两场分赛的排名 x, y,问你最终名次最小和最大可能是多少。 思路: 以8人为例: x + y 阅读全文
posted @ 2020-03-19 20:12 Kanoon 阅读(148) 评论(0) 推荐(0)
摘要:Codeforces Round #622 (Div. 2) A. Fast Food Restaurant 题意: 你是餐馆老板,虽然只会做三道菜,上菜时还有个怪癖:一位客人至少上一道菜,且一种菜最多上一次,所有客人菜单不能相同。给出三种菜的数量,问最多能接收多少客人。 思路: 一人一道 → 一人 阅读全文
posted @ 2020-03-19 18:32 Kanoon 阅读(144) 评论(0) 推荐(0)
摘要:题意: n 点 m 边有向图,给出行走路径,求行走途中到路径终点最短路变化次数的最小值和最大值 。 思路 : 逆向广搜,正向模拟。 #include <bits/stdc++.h> using namespace std; const int M=220000; vector<int> e1[M], 阅读全文
posted @ 2020-03-18 20:22 Kanoon 阅读(179) 评论(0) 推荐(0)
摘要:题意: 给你一个由小写字母组成的字符串,若串中两个相邻元素字典序中也相邻,移除较大字母,问最多能移除多少个字母。 思路: 从大到小依次枚举。 Tips: 注意下标的处理。 以小消大: #include <bits/stdc++.h> using namespace std; int main() { 阅读全文
posted @ 2020-03-18 20:20 Kanoon 阅读(185) 评论(0) 推荐(0)
摘要:题意: 已知 n 所城市(从 1 至 n 编号)及其美丽值,选取一条旅行路线,满足路线中两两城市美丽值之差等于编号之差,求所有旅行路线中美丽值的最大值。 思路: 美丽值与编号作差,差值为键,映射累加 。 #include <bits/stdc++.h> using namespace std; in 阅读全文
posted @ 2020-03-18 20:18 Kanoon 阅读(94) 评论(0) 推荐(0)
摘要:题意: n 道题,2 个答题者,已知二者的做题情况,你是受贿裁判,可以给每题指定分值(≥1),求甲乙分数(甲>乙)相差最小时最大分值的最小值。 思路: 统计只有甲或乙做出的题目数。 加一取下整判同余: #include <bits/stdc++.h> using namespace std; int 阅读全文
posted @ 2020-03-18 20:17 Kanoon 阅读(135) 评论(0) 推荐(0)
摘要:题意: n x m 的网格,p 个玩家轮流BFS,给出每个玩家每次能遍历的最远距离和网格初始状态(可遍历点、障碍点、每个玩家的遍历起点(可多个)),问每个玩家最多能遍历多少点。 Tips: 以所有玩家无法再进行遍历而不是已遍历所有点为终止条件。 #include <bits/stdc++.h> us 阅读全文
posted @ 2020-03-16 17:50 Kanoon 阅读(128) 评论(0) 推荐(0)
摘要:题意: 长为 n,由 l ~ r 中的数组成,其和模 3 为 0 的数组数目。 思路: dp[ i ][ j ] 为长为 i,模 3 为 j 的数组数目。 #include <bits/stdc++.h> using namespace std; const int M=220000; const 阅读全文
posted @ 2020-03-16 17:32 Kanoon 阅读(117) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> using namespace std; int main() { int n,k;cin>>n>>k; string s;cin>>s; int ans[26]={0}; for(int i=0;i<n;i++){ int len=1; while 阅读全文
posted @ 2020-03-16 17:21 Kanoon 阅读(93) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; int a[n];for(int &i:a) cin>>i; int ans_ave=0,ans_cost=INT_MAX; for(int i=1;i< 阅读全文
posted @ 2020-03-16 17:16 Kanoon 阅读(119) 评论(0) 推荐(0)
摘要:题意: 寻找异或后值为 u,相加后和为 v 的最短数组。 思路: 异或得 u ,则 v 至少应大于等于 u ,且多出来的部分可以等分为两份相消。 即初始数组为 u , (v-u)/2 , (v-u)/2,之后即为特判或判断是否可以合并。 #include <bits/stdc++.h> using 阅读全文
posted @ 2020-03-15 02:05 Kanoon 阅读(264) 评论(0) 推荐(1)
摘要:题意: 给有 n 个点的树的 n-1 条边从 0 到 n-2 编号,使得任意两点路径中未出现的最小数最小的方案。 思路: 先给所有度为 1 的点所在边编号,之后其他点可以随意编排。 #include <bits/stdc++.h> using namespace std; const int M=1 阅读全文
posted @ 2020-03-15 01:54 Kanoon 阅读(289) 评论(0) 推荐(1)
摘要:题意: 给你一个数组,可以像题目那样无限拼接,问递增子序列的最大长度(可不连续)。 思路: 序列的最大长度即为数组中不同元素的个数。 Tips: 一开始不知道back-to-back什么意思,看到题目立刻懂了2333。 #include <bits/stdc++.h> using namespace 阅读全文
posted @ 2020-03-15 01:45 Kanoon 阅读(151) 评论(0) 推荐(0)
摘要:题意: GCD(a,b) + LCM(a,b) = n,已知 n ,求 a,b。 思路: 设 gcd(a, b) = k, a = xk, b = yk , k + ab / k = n xy = n/k - 1 令 k = 1 , 则 xy = n - 1 令 x = 1 , 则 y = n - 阅读全文
posted @ 2020-03-15 01:35 Kanoon 阅读(208) 评论(0) 推荐(0)
摘要:题意: LCM(a, b) = X,求 max(a, b) 的最小值。 思路: a, b 只可能存在于 X 的因子中,枚举即可。 #include <bits/stdc++.h> using namespace std; typedef long long ll; ll lcm(ll a,ll b) 阅读全文
posted @ 2020-03-14 22:14 Kanoon 阅读(114) 评论(0) 推荐(0)
摘要:题意: 一个长为n的序列,是否存在与原序列不同的连续子序列,其元素之和大于等于原序列。 思路: 从前、后分别累加,若出现非正和,除此累加序列外的子序列元素之和一定大于等于原序列。 #include <bits/stdc++.h> using namespace std; typedef long l 阅读全文
posted @ 2020-03-14 22:05 Kanoon 阅读(195) 评论(0) 推荐(0)

上一页 1 ··· 6 7 8 9 10 11 下一页