hdu 5532】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=5532  题目大意: 给你一个不规则的序列,问是否能够通过删除一个元素使其成为一个有序的序列(递增或递减(其中相邻的元素可以相等))   将序列里分成两种可能讨论,该序列除了一个元素之外要么递增要么递减,只需满足一个即可   #include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #i…
http://acm.hdu.edu.cn/showproblem.php?pid=5532 题意大致是一组数中去掉一个数后问剩下的数是否构成非严格单调序列 正反各跑一遍最长非严格连续子序列,存在长度大于等于n-1的就满足YES,注意这里的YES NO都是大写 #include<cstdio> using namespace std; ],c[]; int main() { int t,i,j,n; scanf("%d",&t); while (t--) { sca…
给出一个序列(长度>=2),问去掉一个元素后是否能成为单调不降序列或单调不增序列. 对任一序列,先假设其可改造为单调不降序列,若成立则输出YES,不成立再假设其可改造为单调不增序列,若成立则输出YES,不成立则输出NO. 由于持平不影响整体单调性,为了直观,我在以下把“不降”称为“递增/升序”,把“不增”称为“递减/降序”. 递增和递减是对称的,这里先考虑递增,递减改个符号和最值就好. 我们把为维护单调性而去掉的那个点称为“坏点”.由题目的要求,“可改造”可等价于“只存在一个坏点”. 对于“坏点…
Problem Description We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is an overkill to use these algorithms for an almost sorted array. We say an array…
input 1<=T<=2000 2<=n<=10e5 a1 a2 ... an 1<=ai<=10e5 最多二十个n>1000 output 能否从数组中移除一个数使数组变为升序或降序,能输出YES,不能输出NO 做法,用后一个数减前一个数,统计正数的个数和负数的个数,如果全部为正或全部为负肯定可以,一个正或者一个负可能可以,如果这个和前一个或者后一个相加能变成全部正或全部负便可以,因为x1=a[i]-a[i-1],x2=a[i+1]-a[i],则a[i+1]-…
Input The first line contains an integer T indicating the total number of test cases. Each test case starts with an integer n in one line, then one line with n integers a1,a2,…,an. 1≤T≤2000 2≤n≤105 1≤ai≤105 There are at most 20 test cases with n>1000…
题目链接 Problem Description We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is an overkill to use these algorithms for an almost sorted array. We say an a…
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 236    Accepted Submission(s): 113 Problem Description We are all familiar with sorting algorithms: quick sort, merge sort,…
Almost Sorted Array Problem Description We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is an overkill to use these algorithms for an almost sorted arr…
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 8541    Accepted Submission(s): 1982 Problem Description We are all familiar with sorting algorithms: quick sort, merge sort…