#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
vi a;
int lis(int n) {
int INF = INT_MAX;
vector<int> d(n+1, INF);
d[0] = -INF;
for (int i = 0; i < n; i++) {
int j = upper_bound(d.begin(), d.end(), a[i]) - d.begin();
if (d[j-1] < a[i] && a[i] < d[j]) d[j] = a[i];
}
int ans = 0;
for (int i = 0; i <= n; i++) {
if (d[i] < INT_MAX)
ans = i;
}
return ans;
}
int main(){
int n,m;
cin>>n>>m;
a.resize(n,0);
for(int i=0; i<n; i++){
cin>>a[i];
}
cout<<lis(n)<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
1840 KB |
Output is correct |
2 |
Correct |
88 ms |
1860 KB |
Output is correct |
3 |
Correct |
91 ms |
1856 KB |
Output is correct |
4 |
Correct |
110 ms |
1740 KB |
Output is correct |
5 |
Correct |
65 ms |
1836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
628 KB |
Output is correct |
2 |
Correct |
26 ms |
632 KB |
Output is correct |
3 |
Correct |
21 ms |
596 KB |
Output is correct |
4 |
Incorrect |
14 ms |
636 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
43 ms |
1064 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |