Classical dynamic programming:find the longest increasing subsequence.
// 1045. Favorite Color Stripe.cpp: 主项目文件。#include "stdafx.h"#include#include #define max(a,b) a>b?a:b;const int N=203;int hash[N];const int arrMax=10003;int arr[arrMax];int cnt;int dp[arrMax];int longestIncreasingSubsequence(){ for(int i=1;i max) max=dp[i]; } return max;}int main(){ int colorNum,favorateColorNum; scanf("%d%d",&colorNum,&favorateColorNum); memset(hash,0,sizeof(hash)); for(int i=0;i