#include <bits/stdc++.h>
using namespace std;
int n,a[1000001];
vector <int> vec;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i=1;i<=n;++i) cin >> a[i];
for (int i=1;i<=n;++i) {
if (vec.empty() || a[i]+1>vec.back()) vec.push_back(a[i]);
else {
int so=lower_bound(vec.begin(),vec.end(),a[i]+1)-vec.begin();
if (vec[so]==a[i]+1) vec[so]=a[i];
else vec.insert(vec.begin()+max(so-1,0),a[i]);
}
}
cout << vec.size();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
472 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Execution timed out |
2084 ms |
9124 KB |
Time limit exceeded |
6 |
Execution timed out |
2061 ms |
9620 KB |
Time limit exceeded |
7 |
Execution timed out |
2007 ms |
8172 KB |
Time limit exceeded |
8 |
Incorrect |
1801 ms |
8280 KB |
Output isn't correct |
9 |
Incorrect |
1940 ms |
8628 KB |
Output isn't correct |
10 |
Execution timed out |
2061 ms |
8920 KB |
Time limit exceeded |