Defense Lines UVA - 1471

题目传送门

题意:给你一个长度为n的序列,你的任务是删除一个连续的子序列,使得剩下的序列当中有一个长度最大的连续递增子序列。

思路:我们想枚举每一个数字,看他能最多向左和向右可以延伸到哪里,然后我们就可以开始枚举i,j了,但是直接枚举的话时间复杂度是不够,所以我们可以仿造最大上升子序列的方法,进行优化将时间复杂度缩减到O(nlogn),就可以了。

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define MAXN 200010
#define MAXE 210
#define INF 10000000
#define MOD 1000000007
#define LL long long
#define pi acos(-1.0)

using namespace std;

int arr[MAXN];
int Left[MAXN];
int Right[MAXN];
int Min[MAXN];

int main() {
  std::ios::sync_with_stdio(false);
  int T;
  cin >> T;
  for (int kase = 1; kase <= T; ++kase) {
    memset(Left, 0, sizeof(Left));
    memset(Right, 0, sizeof(Right));
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
      cin >> arr[i];
    Left[1] = 1;
    for (int i = 2; i <= n; ++i) {
      if (arr[i] > arr[i - 1])
        Left[i] = Left[i - 1] + 1;
      else
        Left[i] = 1;
    }
    Right[n] = 1;
    for (int i = n - 1; i >= 1; --i) {
      if (arr[i] < arr[i + 1])
        Right[i] = Right[i + 1] + 1;
      else
        Right[i] = 1;
    }
    int ans = 0;
    memset(Min, 0x3f, sizeof(Min));
    for (int i = 1; i <= n; i++) {
      int len = lower_bound(Min + 1, Min + 1 + n, arr[i]) - Min - 1;
      ans = max(ans, Right[i] + len);
      Min[Left[i]] = min(Min[Left[i]], arr[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

/*
2
9
5 3 4 9 2 8 6 7 1
7
1 2 3 10 4 5 6
*/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Color-based model-free tracking is a popular technique used in computer vision to track objects in video sequences. Despite its simplicity, it has demonstrated high accuracy and robustness in various applications, such as surveillance, sports analysis, and human-computer interaction. One of the key advantages of color-based model-free tracking is its real-time performance. Unlike model-based tracking, which requires complex training and computation, color-based tracking can be implemented using simple algorithms that can run in real-time on low-power devices. This makes it suitable for applications that require fast response time, such as robotics and autonomous systems. Another advantage of color-based tracking is its ability to handle occlusions and partial occlusions. Since color features are less sensitive to changes in lighting and viewing conditions, the tracker can still maintain its accuracy even when the object is partially hidden or obstructed by other objects in the scene. Critics of color-based tracking argue that it is not effective in complex scenes where the object of interest may have similar colors to the background or other objects in the scene. However, recent advancements in machine learning and deep learning have enabled the development of more sophisticated color-based tracking algorithms that can accurately detect and track objects even in challenging scenarios. In summary, color-based model-free tracking is a simple yet effective technique for tracking objects in video sequences. Its real-time performance, robustness, and ability to handle occlusions make it a popular choice for various applications. While it may not be suitable for all scenarios, advancements in machine learning are making it more effective in complex scenes.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值