题目: 求一个数组的最长递减子序列比 , 如随机生成一组序列 {8,9,6,3,6,2,3,4} 求得最长递减序列 {9,8,6,4,3,2} list=[3,3,3,3,6,2,3,4] //冒泡排序 n=len(list) for i in range(0,n-2): for k in range(0,n-1): if list[k+1]>list[k]: list[k+1],list[k]=list[k],list[k+1] print(list) result=[] for i in…
题目链接 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…
D. Once Again... You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of…
题意:给一串由n个数字组成的字符串,选择其中一个区间进行翻转,要求翻转后该字符串的最长非降子序列长度最长,输出这个最长非降子序列的长度以及翻转的区间的左右端点 #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ; int n, a[maxn], dp[maxn][maxm], b[maxm]; int ans, ansl, ansr, l, r, cnt; int al[maxn][maxm], ar[ma…
Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 27358 Accepted Submission(s): 7782 Problem Description JGShining's kingdom consists of 2n(n is no mor…
A. Kefa and First Steps time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 …
A person wants to travel around some places. The welfare in his company can cover some of the airfare cost. In order to control cost, the company requires that he must submit the plane tickets in time order and the amount of the each submittal must b…