codeforces 1830e bully sort

Codeforces Round 881 (Div. 3)

Codeforces Round 881 (Div. 3) A: void solve(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } sort(a+1,a+1+n); int ans=0; int l=1; int r=n; for(in ......
Codeforces Round 881 Div

CodeForces 合集

# 1838E. Count Supersequences https://codeforces.com/contest/1838/problem/E ## 题意 给定 $n, m, k$,一个长度为 $n$ 的序列 $a = (a_1, a_2, \dots, a_n)$,满足 $1 \leq a ......
CodeForces

20230407 Arrays.sort

分析以下方法: - Arrays#sort(int[]) - Arrays#sort(Object[] a) ## DualPivotQuicksort - Arrays#sort(int[]) 使用 DualPivotQuicksort - Dual-Pivot Quicksort 是一种快速排序 ......
20230407 Arrays sort

Codeforces Round 880 (Div. 2) C. k-th equality

看好久题目了,题目大意是给定三个位数A,B,C和一个k,要求求所有满足要求的a+b=c等式中的第k个等式 等式按字典序由小到大枚举,例如1+9=10和2+6=8中1+9=10比2+6=8小 思路我们首先求出a,b,c的取值范围,然后先确定a,对于每一个确定的a都有一个确定的b和c区间与之对应,并且a ......
Codeforces equality Round k-th 880

Codeforces Round 879 (Div. 2) 题解

寄!大!了! Rating -= 124. ![image](https://img2023.cnblogs.com/blog/3143679/202306/3143679-20230619222246244-5109748.png) (恼) https://codeforces.com/conte ......
题解 Codeforces Round 879 Div

Codeforces 1834 / Codeforces Round #879 (Div. 2)

[TOC] ### Contest Link [Codeforces Round #879 (Div. 2)](https://codeforces.com/contest/1834) ### Problem B [Maximum Strength](https://codeforces.com/c ......
Codeforces Round 1834 879 Div

Codeforces Round 880 (Div. 2) B. Astrophysicists

昨天晚上卡B题了,掉大分,qwq 现在回想起来昨天没反应过来 题目要求为公司节省最多的钱 我们可以发现如果n个人,每个人的分的钱都小于g/2且者n个人分的钱加起来恰好为k*g的话则公司一分钱都不用花 第一种情况 假设每个人分的钱都为h则最理想的情况为h*n>=k*g且h<g/2,即h=g/2-1 如 ......
Astrophysicists Codeforces Round 880 Div

Codeforces Round 879 (Div

# [Codeforces Round 879 (Div. 2)](https://codeforces.com/contest/1834) A-D题解 第一次写题解,请见谅O3O a题代码是完整的,后面的只显示主要内容的代码 ## A. Unit Array 题目解释 他会给你一个只包含1或者-1 ......
Codeforces Round 879 Div

Codeforces1 #879 div.2

第一次参加codeforces比赛,只能做出来俩题,第三个题思路也就一半一半,估计是想不出来的那种,赛后问了下带佬,把我思路添加了点,最终还是A了 争取稳过第三题! //A //统计1,-1出现的次数,然后如果-1是奇数,让他变成偶数,次数+1 //因为总乘积要是正1,然后再变-1为1,直到>=0为 ......
Codeforces1 Codeforces 879 div

Codeforces Round 880 (Div. 2) 题解 A - C

## 写在前面 感觉题目是一坨。 A愣了一会,BC同开然后半天读不懂题。写出来发现毛算法都没有,div1那边更是大寄。DEF三题过题数个位数根本看都看不来。总结为很烂的一场。 ## [A](https://codeforces.com/contest/1836/problem/A). Destroy ......
题解 Codeforces Round 880 Div

Educational Codeforces Round 150 (Rated for Div. 2) C. Ranom Numbers

#include <iostream> #include <string> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int N=2e5+10; typedef long l ......
Educational Codeforces Numbers Round Rated

Educational Codeforces Round 150 (Rated for Div. 2) B. Keep it Beautiful

#include <iostream> #include <cstring> using namespace std; const int N=2e5+10; int a[N],res[N]; int t; int main(){ cin>>t; while(t--){ int n; cin>>n; ......
Educational Codeforces Beautiful Round Rated

CodeForces 1841C Ranom Numbers

[洛谷传送门](https://www.luogu.com.cn/problem/CF1841C "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1841/C "CF 传送门") 先反转 $s$ 串,然后考虑 dp,设 $f_{ ......
CodeForces Numbers 1841C Ranom 1841

CF1830E Bully Sort

[题面传送门](https://www.luogu.com.cn/problem/CF1830E) 我们考虑选中的 $i$,这个位置一定是 $p_i>i$,它想要往后走。而和它交换的 $j$,因为 $\leq i$ 的有 $i$ 个数,现在第 $i$ 个位置已经被 $p_i$ 占据了,所以 $\le ......
1830E Bully 1830 Sort CF

Educational Codeforces Round 150 (Rated for Div. 2)题解(A~D)

比赛地址 A. Game with Board 题意: 给出一个包含n个1的数组,Alice和Bob轮流操作(Alice先手),每次操作可以将若干个(最少为两个)不同的元素相加,组成一个新的元素插入数组中,同时删去被操作的元素。当轮到某名玩家时无法再进行操作,则该玩家获胜。 思路: 容易想到,当n= ......
题解 Educational Codeforces Round Rated

python高阶函数filter、sorted学习笔记

# filter Python内建的filter()函数用于过滤序列。 和map()类似,filter()也接收一个函数和一个序列。和map()不同的是,filter()把传入的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素。 e.g在一个list中,删掉偶数, ......
高阶 函数 笔记 python filter

Codeforces Round 855 (Div. 3)

`https://codeforces.com/contest/1800` **E. Unforgivable Curse** 题意:输入两个字符串s,t , 每次修改可以交换相距k或k+1位置的字母,能否将将s修改为t。 方法:首先,两个字符串必须由相同元素,且每种元素的个数相等。其次,元素可以先 ......
Codeforces Round 855 Div

reversed 和 sorted 函数

a = 'abcxd' print(reversed(a)) # <reversed object at 0x000000000356F048> print(list(reversed(a))) # ['d', 'x', 'c', 'b', 'a'] print(sorted(a)) # ['a', ......
函数 reversed sorted

CodeForces 1839E Decreasing Game

[洛谷传送门](https://www.luogu.com.cn/problem/CF1839E "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1839/E "CF 传送门") 不会,不知道该如何评价。确实是自己的问题。 这种 ......
CodeForces Decreasing 1839E 1839 Game

Educational Codeforces Round 150 (Rated for Div. 2) 题解

https://codeforces.com/contest/1841 https://codeforces.com/contest/1841/problems # D. Pairs of Segments https://codeforces.com/contest/1841/problem/D ......
题解 Educational Codeforces Round Rated

Remove Duplicates from Sorted Array

**Example 1:** ``` Input: nums = [1,1,2] Output: 2, nums = [1,2,_] Explanation: Your function should return k = 2, with the first two elements of nums ......
Duplicates Remove Sorted Array from

Codeforces Round 877 (Div.2) 题解 A - D

## [A](https://codeforces.com/contest/1838/problem/A). Blackboard List ### 题目大意 起初黑板上有两个数,现在不断选取两个数作出他们俩差的绝对值并写在黑板上,如此往复直到黑板上有 $n$ 个数。现在给定这 $n$ 个数,问起初 ......
题解 Codeforces Round 877 Div

Codeforces Round 877 (Div. 2)

# Preface 补题 这场补题的时候直接成腐乳了,A题挂两发,B题挂两发,C题挂一发是真的抽象 虽然D是个套路题看一眼就秒了,但如果真的比赛时候打真要罚时爆炸了的说 后面的EF还是做不来啊岂可修,不过都很有启发性让人感觉神清气爽,不像傻逼蓝桥杯花钱买罪受 # A. Blackboard List ......
Codeforces Round 877 Div

Codeforces Round 876 Div2 A-D题解

# Codeforces Round 876 Div2 A-D题解 # A.The Good Array 这个题就是问你对于 $i \leq n$,要求前面后面至少 $ceil(\frac{i}{k})$ 个 1 那我们就贪心的每k个放一个1,或者直接用数学算一下就好了 AC 代码 ```cpp # ......
题解 Codeforces Round Div2 876

[Codeforces Round 876 (Div. 2)][Codeforces 1839D. Ball Sorting]

题目链接:[D - Ball Sorting](https://codeforces.com/contest/1839/problem/D) 题目大意:需要对一个排列按照指定操作进行排序。操作一:在数字间插入一个特殊点,可执行不超过 $k$ 次;操作二:将在特殊点旁的数移动到任意位置。所有操作结束后 ......
Codeforces Sorting Round 1839 Ball

Codeforces 1188D Make Equal

设最终所有数变为的值为 $u$,$\operatorname{bitcount}(x)$ 为 $x$ 二进制上为 $1$ 的位数,由题可得答案即为 $\sum\limits_{i = 1}^n \operatorname{bitcount}(u - a_i)$。 此时让 $a_i$ 从小到大排序,答 ......
Codeforces 1188D Equal 1188 Make

Codeforces 1626 C

# [1626 C](https://codeforces.com/problemset/problem/1626/C) ## 题意 抽象出题意:给出n个区间的结尾以及它的区间长度,然后每一段连续区间的贡献为$\sum_{i=1}^{len} i$ ,求总贡献。 ## 思路 处理出每个区间的开头结尾 ......
Codeforces 1626

CodeForces 1840G In Search of Truth

[洛谷传送门](https://www.luogu.com.cn/problem/CF1840G2 "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1840/G2 "CF 传送门") 每次询问获得的信息只有当前所在位置的数字。考 ......
CodeForces Search 1840G Truth 1840

Codeforces 1514 C

# [1514 C](https://codeforces.com/problemset/problem/1514/C) ## 题意 给出一个数n,求[1,2,3...n-1]的某个最长子序列,这个子序列的元素乘积模n余1。 ## 思路 这是个思维题,一个数学公式 $$x \equiv 1(mod  ......
Codeforces 1514

js数组sort方法排序

数组的sort方法可以对数组进行排序,默认是按照字符编码的顺序进行排序,可以自定义规则。 sort方法会修改原数组。 自定义规则简述:比较函数两个参数 a 和 b,(a是b的后一个元素),返回 a-b 升序,返回 b-a 降序。 ```javascript let arr = [3,5,2,9,1] ......
数组 方法 sort