leetcode

🏆leetcode 记录leetcode中的题目🤡 在此文件中更新🧐 ...

November 23, 2020 · 10 min · 2002 words · eonh1u

cf-595-div3

A:Yet Another Dividing into Teams 题目: You are a coach of a group consisting of 𝑛 students. The 𝑖-th student has programming skill 𝑎𝑖. All students have distinct programming skills. You want to divide them into teams in such a way that: No two students 𝑖 and 𝑗 such that |𝑎𝑖−𝑎𝑗|=1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1); the number of teams is the minimum possible. You have to answer 𝑞 independent queries. ...

October 23, 2019 · 11 min · 2305 words · eonh1u

cf-594-div2

A: Integer Points 题目: DLS and JLS are bored with a Math lesson. In order to entertain themselves, DLS took a sheet of paper and drew 𝑛 distinct lines, given by equations 𝑦=𝑥+𝑝𝑖 for some distinct 𝑝1,𝑝2,…,𝑝𝑛. Then JLS drew on the same paper sheet 𝑚 distinct lines given by equations 𝑦=−𝑥+𝑞𝑖 for some distinct 𝑞1,𝑞2,…,𝑞𝑚. DLS and JLS are interested in counting how many line pairs have integer intersection points, i.e. points with both coordinates that are integers. Unfortunately, the lesson will end up soon, so DLS and JLS are asking for your help. ...

October 22, 2019 · 7 min · 1351 words · eonh1u

cf-593-div2

A:Stones 题目: Alice is playing with some stones. Now there are three numbered heaps of stones. The first of them contains 𝑎 stones, the second of them contains 𝑏 stones and the third of them contains 𝑐 stones. Each time she can do one of two operations: take one stone from the first heap and two stones from the second heap (this operation can be done only if the first heap contains at least one stone and the second heap contains at least two stones); ...

October 19, 2019 · 8 min · 1667 words · eonh1u

cf-Global Round 5

A:Balanced Rating Changes 题目: Another Codeforces Round has just finished! It has gathered 𝑛 participants, and according to the results, the expected rating change of participant 𝑖 is 𝑎𝑖. These rating changes are perfectly balanced — their sum is equal to 0. Unfortunately, due to minor technical glitches, the round is declared semi-rated. It means that all rating changes must be divided by two. There are two conditions though: ...

October 19, 2019 · 8 min · 1541 words · eonh1u

51nod-2594-括号之价

题目: 小Y上数据结构课的时候摸鱼,听到老师在讲用栈做括号匹配,于是乎边随意写了一个合法的括号序列。但是光是写括号太无聊了,他现在想知道这个括号序列的价值。他是这样定义一个括号序列的价值的: 1、一对括号价值一分(比如"()“得一分) 2、两个合法的括号序列的拼接而成的括号序列的价值是他们的价值的和(比如”()()“价值为1+1=2) 3、嵌套的括号的序列的价值是,所嵌套的括号序列的价值的翻倍(比如”((()))“价值为1*2*2=4) 下课了,qz看到小Y写的括号序列,他一眼就推测出了规则并得到了括号序列的价值。那么问题来了,小Y写下的括号序列的价值是多少呢? ...

October 16, 2019 · 1 min · 118 words · eonh1u

51nod-2531-最大覆盖

题目: 现在有 𝑛 个位置 1…𝑛 。 给𝑞个区间,请你选出选𝑞−2个,使得覆盖位置个数最大。 输入 第一行两个数n,q(3<=n,q<=5000)。 接下来q行,其中第i行两个数l[i],r[i],表示第i个区间能覆盖所有满足l[i]<=x<=r[i]的位置x。 ...

October 15, 2019 · 1 min · 206 words · eonh1u

51nod-2523-小b删列

题目: b有一个n*m的矩阵A,矩阵的每个元素为一个字符,现在她希望删除其中的一些列,使得剩下的列在每一行形成的字符串的字典序不降。 即对于第i行,将剩下的列上的字符顺序拼接,形成一个字符串,字符串记作a[i]。要求a[i]<=a[i+1](i=1..n-1)。 请问小b最少要删多少列。 如A = {“abcdef”, “uvwxyz”},删除的列为第1,3,4列,删除后 A 为 {“bef”, “vyz”},且 “bef” <= “vyz” 样例解释: 删掉第一列,剩下的是"a" “b” “c”,“a” <= “b” <= “c”,满足条件。 ...

October 15, 2019 · 2 min · 282 words · eonh1u

51nod-2522-和为k的倍数

题目: 小b喜欢和为K的倍数的序列。 现在有一个长度为n的序列A,请问A有多少个非空连续子序列是小b喜欢的。 输入 第一行输入一个正整数n; 第二行输入n个整数,表示A[i],以空格隔开; 第三行输入一个正整数K; 其中1≤n≤30000,对于任意A[i]有-10000≤A[i]≤10000,2≤K≤10000 输出 输出一个数,表示子序列的数目 ...

October 15, 2019 · 1 min · 107 words · eonh1u

51nod-2513-重排列

题目: 有两个长度为n的序列A,B,你需要重排列A,使得满足A[i]>B[i]的i的数目尽量大。 只需输出这个最大个数即可。 输入 第一行输入一个正整数n; 第二、三行分别输出n个非负整数,表示A、B中的元素,以空格隔开; 其中1≤n≤10000,0≤A[i],B[i]≤10^9。 输出 输出一行一个数,表示最大个数 ...

October 15, 2019 · 1 min · 103 words · eonh1u