#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
int lst[1000005];
vector<int> arr;
int binser(int x) {
int l = 0, r = arr.size(), ans = -1;
r--;
while(l <= r) {
int mid = (l + r) / 2;
if (arr[mid] <= x) {
ans = mid;
l = mid + 1;
}
else {
r = mid - 1;
}
}
return ans;
}
int main() {
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> lst[i];
}
int l = 1;
int ans = 0;
while(l <= n) {
ans++;
int loc = binser(lst[l]);
int r = l;
while(r + 1 <= n && lst[r + 1] >= lst[r] && loc == binser(lst[r + 1])) {
r++;
}
for(int i = l; i <= r; i++) {
arr.push_back(lst[i]);
}
sort(arr.begin(), arr.end());
//cout << l << " " << r << endl;
l = r + 1;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |