-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLIS.cpp
More file actions
34 lines (30 loc) · 655 Bytes
/
LIS.cpp
File metadata and controls
34 lines (30 loc) · 655 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//×µÝÔö×Ó´®µÄ³¤¶È
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int lis(int a[], int length) {
int *b = new int[length];
int res = 1;
for(int i = 0; i < length; i++) {
b[i] = 1;
for(int j = 0; j < i; j++) {
if(a[i] > a[j] )
b[i] = max(b[i], b[j] + 1);
}
res = max(res, b[i]);
}
return res;
}
int main(int argc, char* argv[])
{
freopen("input.txt", "r", stdin);
int arr[100];
int i = 0;
while(cin>>arr[i++]);
printf("%d\n", lis(arr, i-1));
return 0;
}