正反跑一次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[],int len)
{

int
ret=;
memset(dp,,sizeof(dp));
for
(int i=;i<=len;i++)
{

if
(a[i] > dp[ret]) dp[++ret]=a[i];
else

{

int
pos=lower_bound(dp+,dp+ret,a[i])-dp;
dp[pos]=a[i];
}
}

return
ret;
}

int
b[],c[];
int
main()
{

int
t;
scanf("%d",&t);
while
(t--)
{

int
n,k;
scanf("%d %d",&n,&k);
int
pos=n-;
for
(int i=;i<=n;i++)
{

scanf("%d",&b[i]);
c[pos--]=b[i];
}

int
mx=max(LIS(c,n),LIS(b,n));
if
(n-mx<=k) cout<<"A is a magic array."<<endl;
else
cout<<"A is not a magic array."<<endl;
}

return
;
}

心情不太好,过来这么久才整理代码。 感情这个东西,比算法难多了

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

  1. hdu 6197 2017 ACM/ICPC Asia Regional Shenyang Online array array array【最长不上升子序列和最长不下降子序列】

    hdu 6197 题意:给定一个数组,问删掉k个字符后数组是否能不减或者不增,满足要求则是magic array,否则不是. 题解:队友想的思路,感觉非常棒!既然删掉k个后不增或者不减,那么就先求数组 ...

  2. LeetCode 80 Remove Duplicates from Sorted Array II [Array/auto] <c++>

    LeetCode 80 Remove Duplicates from Sorted Array II [Array/auto] <c++> 给出排序好的一维数组,如果一个元素重复出现的次数 ...

  3. js Array.from & Array.of All In One

    js Array.from & Array.of All In One 数组生成器 Array.from The Array.from() static method creates a ne ...

  4. Array.fill & array padding

    Array.fill & array padding arr.fill(value[, start[, end]]) https://developer.mozilla.org/en-US/d ...

  5. HDU 6197 array array array 2017沈阳网络赛 LIS

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6197 题意:给你n个数,问让你从中删掉k个数后(k<=n),是否能使剩下的序列为非递减或者非递增 ...

  6. HDU - 6197:array array array (简单LIS)

    One day, Kaitou Kiddo had stolen a priceless diamond ring. But detective Conan blocked Kiddo's path ...

  7. hdu 6197 array array array

    array array array Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  8. HDU - 6197 array array array (最长上升子序列&最长下降子序列)

    题意:对于一个序列,要求去掉正好K个数字,若能使其成为不上升子序列或不下降子序列,则“A is a magic array.”,否则"A is not a magic array.\n&qu ...

  9. hdu 5280 Senior's Array

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5280 Senior's Array Description One day, Xuejiejie ge ...

随机推荐

  1. nginx配置监控

    通过查看Nginx的并发连接,我们可以更清除的知道网站的负载情况.Nginx并发查看有两种方法(之所以这么说,是因为笔者只知道两种),一种是通过web界面,一种是通过命令,web查看要比命令查看显示的 ...

  2. openjudge计算概论-大整数加法

    /*=====================================================================1004:大整数加法总时间限制: 1000ms 内存限制: ...

  3. 关于form与表单提交操作的一切

    原文链接:http://caibaojian.com/form.html 你知道,一个表单里面只要有form元素,如果没有给action加一个默认值,为空白的时候,当你刷新页面时,会弹出一个警告框提示 ...

  4. 如何查看SWT源代码和帮助文档

    如何查看SWT源代码https://blog.csdn.net/wzq__janeGreen_/article/details/80068998

  5. LC 992. Subarrays with K Different Integers

    Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A g ...

  6. Java 5-11新特性的整理(转)

    Java 5-11新特性的整理(转) 作者:拔剑少年 简书地址:https://www.jianshu.com/u/dad4d9675892博客地址:https://it18monkey.github ...

  7. ABAP程序并行处理

    CASE1. 程序中 start new task ,并在后面获取处理结果 *"------------------------------------------------------- ...

  8. UIwindow ---密码框

    程序运行显示结果如下 : 验证密码输入错误显示如下: 代码如下 : 1> ////  PasswordInputWindow.m//  UIWindow--密码框////  Created by ...

  9. css mix-blend-mode 混合模式

    CSS3混合模式种类 在CSS3混合模式中,目前仅有16种:normal,multiply,screen,overlay,darken,lighten,color-dodge,color-burn,h ...

  10. 海量无损高音质音乐文件分享180TB(持续更新)

    海量无损高音质音乐文件分享180TBWAV,flac,ape格式(持续更新),由于本人是音乐发烧爱好者,收集海量的无损音乐,已经分类好了,比较方便查找,但是本地没法存储,所有放在网盘中,并且我这边还会 ...