随笔分类 - 算法-刷题题目
牛客,leetcode,codeforces
摘要:问题一: 传送门 给定一个整数数组,返回所有数对之间的第 k 个最小距离。一对 (A, B) 的距离被定义为 A 和 B 之间的绝对差值。 示例 1: 输入:nums = [1,3,1]k = 1输出:0 解释:所有数对如下:(1,3) -> 2(1,1) -> 0(3,1) -> 2因此第 1 个
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/7817/H来源:牛客网 Listening to the rock music permutes your nuclear DNA. This astonishing and unbelievable fact was
阅读全文
摘要:题目描述 给你一个整数数组 nums ,你可以在 nums 上执行下述操作 任意次 : 如果 gcd(nums[i], nums[j]) > 1 ,交换 nums[i] 和 nums[j] 的位置。其中 gcd(nums[i], nums[j]) 是 nums[i] 和 nums[j] 的最大公因数
阅读全文
摘要:题目描述 你正在参加一个多角色游戏,每个角色都有两个主要属性:攻击 和 防御 。给你一个二维整数数组 properties ,其中 properties[i] = [attacki, defensei] 表示游戏中第 i 个角色的属性。 如果存在一个其他角色的攻击和防御等级 都严格高于 该角色的攻击
阅读全文
摘要:题目描述 传送门 题目大意:给出一个长度为 n 的数组 a 和计算贡献的数组 sum,需要执行 m 次操作,每次操作分为下列两种类型: 1 l r x:将区间 [ l , r ] 内的 a 用 x 覆盖,即 i ∈[ l , r] , a[ i ] = x,且 sum[ i ] += abs( a[
阅读全文
摘要:例一: 传送门 题意: 就是给你$n$个物品,每一个物品都有一个体积$v[i]$,然后给你$m$个箱子,问你这个箱子的最小的体积是多少才能将这些物品都放到这m个箱子里 n,m(1≤n,m≤1000),v1,v2…,vn ( 1≤v1,v2,…,vn≤1000) 1 5 3 1 2 3 4 5 Cas
阅读全文
摘要:题目 题目描述 题目链接 Lena is the most economicalgirl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best sto
阅读全文
posted @ 2021-07-31 17:12
lipu123
摘要:题目: 题目链接 You are given two integers nn and mm. Find the MEXMEX of the sequence n⊕0,n⊕1,…,n⊕mn⊕0,n⊕1,…,n⊕m. Here, ⊕ is the bitwise XOR operator. MEX of
阅读全文
摘要:题目 题目链接 题目描述 有 n 个人排成一个队列,从左到右 编号为 0 到 n - 1 。给你以一个整数数组 heights ,每个整数 互不相同,heights[i] 表示第 i 个人的高度。 一个人能 看到 他右边另一个人的条件是这两人之间的所有人都比他们两人 矮 。更正式的,第 i 个人能看
阅读全文
摘要:This problem is an extension of the problem "Wonderful Coloring - 1". It has quite many differences, so you should read this statement completely. Rec
阅读全文
摘要:题目: 传送门: Consider a sequence of integers a1,a2,…,an In one move, you can select any element of the sequence and delete it. After an element is deleted
阅读全文
摘要:题目: 题目链接: Description Input The first line contains an integer T . Then T test cases follow. Each test case contains three lines. The first one contai
阅读全文
摘要:The land of a park AtCoder is an N×N grid with east-west rows and north-south columns. The height of the square at the i-th row from the north and j-t
阅读全文
摘要:1937. 扣分后的最大得分 给你一个 m x n 的整数矩阵 points (下标从 0 开始)。一开始你的得分为 0 ,你想最大化从矩阵中得到的分数。 你的得分方式为:每一行 中选取一个格子,选中坐标为 (r, c) 的格子会给你的总得分 增加 points[r][c] 。 然而,相邻行之间被选
阅读全文
摘要:1931. 用三种不同颜色为网格涂色 给你两个整数 m 和 n 。构造一个 m x n 的网格,其中每个单元格最开始是白色。请你用 红、绿、蓝 三种颜色为每个单元格涂色。所有单元格都需要被涂色。 涂色方案需要满足:不存在相邻两个单元格颜色相同的情况 。返回网格涂色的方法数。因为答案可能非常大, 返回
阅读全文
摘要:You have a maze with obstacles and non-zero digits in it: You can start from any square, walk in the maze, and finally stop at some square. Each step,
阅读全文