hdu 6197 array array array LIS】的更多相关文章

hdu 6197 题意:给定一个数组,问删掉k个字符后数组是否能不减或者不增,满足要求则是magic array,否则不是. 题解:队友想的思路,感觉非常棒!既然删掉k个后不增或者不减,那么就先求数组的最长不下降子序列的长度l1和最长不上升子序列的长度l2,若l1>=n-k||l2>=n-k,则满足要求. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm&g…
LeetCode 80 Remove Duplicates from Sorted Array II [Array/auto] <c++> 给出排序好的一维数组,如果一个元素重复出现的次数大于两次,删除多余的复制,返回删除后数组长度,要求不另开内存空间. C++ 献上自己丑陋无比的代码.相当于自己实现一个带计数器的unique函数 class Solution { public: int removeDuplicates(std::vector<int>& nums) {…
js Array.from & Array.of All In One 数组生成器 Array.from The Array.from() static method creates a new, shallow-copied Array instance from an array-like or iterable object. Array.from()静态方法从类似数组或可迭代的对象中创建一个新的,浅复制的Array实例. Array.from(arrayLike [, mapFn [,…
Array.fill & array padding arr.fill(value[, start[, end]]) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill const log = console.log; const arr = [...new Uint8Array(4)]; //const arr = [1, 2, 3, 4]; log(arr);…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6197 题意:给你n个数,问让你从中删掉k个数后(k<=n),是否能使剩下的序列为非递减或者非递增序列 解法:签到题,就是让你求最长不下降子序列长度len,然后判断下n-len是否小于k(将序列反着存下来然后再求即最长不上升子序列,取两者len中的较大值),然后直接套nlogn的模板即可. #include <bits/stdc++.h> using namespace std; const…
正反跑一次LIS,取最大的长度,如果长度大于n-k就满足条件. ac代码: #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <map> #include <stack> #include <algorithm> using namespace std; int dp]; int LIS(int a[],in…
One day, Kaitou Kiddo had stolen a priceless diamond ring. But detective Conan blocked Kiddo's path to escape from the museum. But Kiddo didn't want to give it back. So, Kiddo asked Conan a question. If Conan could give a right answer, Kiddo would re…
array array array Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 459    Accepted Submission(s): 282 Problem Description One day, Kaitou Kiddo had stolen a priceless diamond ring. But detective…
题意:对于一个序列,要求去掉正好K个数字,若能使其成为不上升子序列或不下降子序列,则“A is a magic array.”,否则"A is not a magic array.\n". 分析: 1.求一遍LCS,然后在将序列逆转,求一遍LCS,分别可得最长上升子序列和最长下降子序列的长度tmp1.tmp2. 2.n - tmp1 <= k或n - tmp2 <= k即可,需要去掉的去完之后,在已经是最长上升或最长下降的序列中随便去够k个就好了. #include<…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5280 Senior's Array Description One day, Xuejiejie gets an array $A$. Among all non-empty intervals of $A$, she wants to find the most beautiful one. She defines the beauty as the sum of the interval. Th…