FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Competitive-Programming/Algorithms/LCS.java at master · joney000/Java-Competitive-Programming · GitHub
joney000
/
Java-Competitive-Programming
Public
Notifications
You must be signed in to change notification settings
Fork
30
Star
123
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Competitive-Programming
/
Algorithms
/
LCS.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
60 lines (47 loc) · 1.25 KB
Breadcrumbs
Java-Competitive-Programming
/
Algorithms
/
LCS.java
Copy path
File metadata and controls
executable file
·
60 lines (47 loc) · 1.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import
java
.
io
.*;
import
java
.
util
.*;
import
java
.
text
.*;
import
java
.
math
.*;
import
java
.
util
.
regex
.*;
class
A
{
static
int
CeilIndex
(
int
A
[],
int
l
,
int
r
,
int
key
)
{
int
m
;
while
(
r
-
l
>
1
) {
m
=
l
+ (
r
-
l
)/
2
;
if
(
A
[
m
] <=
key
)
r
=
m
;
else
l
=
m
;
}
return
r
;
}
static
int
LongestIncreasingSubsequenceLength
(
int
A
[],
int
size
) {
int
[]
tailTable
=
new
int
[
size
];
int
len
;
for
(
int
i
=
0
;
i
<
size
;++
i
)
tailTable
[
i
] =
0
;
tailTable
[
0
] =
A
[
0
];
len
=
1
;
for
(
int
i
=
1
;
i
<
size
;
i
++ ) {
if
(
A
[
i
] >
tailTable
[
0
] )
tailTable
[
0
] =
A
[
i
];
else
if
(
A
[
i
] <
tailTable
[
len
-
1
] )
tailTable
[
len
++] =
A
[
i
];
else
tailTable
[
CeilIndex
(
tailTable
, -
1
,
len
-
1
,
A
[
i
])] =
A
[
i
];
}
return
len
;
}
public
static
void
main
(
String
[]
args
) {
Scanner
sc
=
new
Scanner
(
System
.
in
);
int
N
=
sc
.
nextInt
();
int
[]
arr
=
new
int
[
N
];
for
(
int
i
=
0
;
i
<
N
;++
i
)
arr
[
i
] =
sc
.
nextInt
();
long
n
=
LongestIncreasingSubsequenceLength
(
arr
,
N
);
n
=
n
*(
n
-
1
)*(
n
-
2
);
n
/=
6
;
System
.
out
.
println
(
n
);
}
}
Back
|
FazBrowse Home
|
New Git URL